Buy real YouTube subscribers. Best price and warranty.
Get Free YouTube Subscribers, Views and Likes

Thread Pools in Java

Follow
Jakob Jenkov

A Thread Pool is an alternative to creating a new thread per task to execute. Instead, a number of precreated threads exist in a pool into which you can submit tasks to be executed by these pooled threads. New tasks submitted to the pool are first stored internally in a queue. From this queue the pooled threads will take the tasks and execute them. Each thread in the thread pool executes in a loop that takes a new task from the internal task queue in the thread pool (or block if no tasks are available), executes the task, and then tries to take another task etc. repeatedly. In this thread pool tutorial I explain in more detail how thread pools work, and show a thread pool implementation in Java. To access the code, click on the link to the textual version of this thread pool tutorial.

Chapters:
0:00 Thread Pool Introduction
1:49 Thread Pool Load Balancing Between Threads
3:00 Using the implemented Thread Pool ThreadPool
6:48 The Implementation of the ThreadPool class.
12:10 The Implementation of the ThreadPoolRunnable class.
16:12 Summary of use of the ThreadPool implementation.

Thread Pool Tutorial text:
http://tutorials.jenkov.com/javaconc...

Java ExecutorService Tutorial (builtin Java Thread Pool) text:
http://tutorials.jenkov.com/javautil...

Java Concurrency Playlist:
   • Java Concurrency and Multithreading  

posted by barbolasblogzi