Thread Pools in Java

Published: 01 January 1970
on channel: Jakob Jenkov
67,929
1.5k

A Thread Pool is an alternative to creating a new thread per task to execute. Instead, a number of pre-created 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/java-conc...

Java ExecutorService Tutorial (built-in Java Thread Pool) - text:
http://tutorials.jenkov.com/java-util...

Java Concurrency Playlist:
   • Java Concurrency and Multithreading  


On this page of the site you can watch the video online Thread Pools in Java with a duration of hours minute second in good quality, which was uploaded by the user Jakob Jenkov 01 January 1970, share the link with friends and acquaintances, this video has already been watched 67,929 times on youtube and it was liked by 1.5 thousand viewers. Enjoy your viewing!