Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 923 Bytes

File metadata and controls

26 lines (21 loc) · 923 Bytes

fluffyThreadPool

WARNING: NOT FINISHED. MAY CONTAIN BUGS.

Another Thread Pool implementation in Java.

This Thread Pool will create a given Number of worker Threads and Idle all of them. Tasks can be given to the pool as Runnables. If there is an idling worker, it instantly executes the runnable. If not, the runnable is added to a queue and every time a Thread goes to Idle, the oldest element of the queue is processed by this Thread.

This is a really simple (or stupid...) scheduling algorithm. A more complex and more efficient scheduling system will be added to the Project later.

Example Code:

/* Constructor needs max Number of Threads and PrintStream to print messages to (or null). */
Pool pool = new Pool(1, System.out);
Runnable exampleRun = new Runnable() {
		@Override
		public void run() {
			System.out.println("Hello ThreadPool World!");
		}
	};
pool.execute(exampleRun);
pool.shutdown();