Six kinds of thread pool

1.FixedThreadPool

The most common thread pool, you can specify the number of thread size. Creating a thread is a common thread

2. SingleThreadPool

1 is the number of threads thread pool, so you can ensure an orderly

3. CacheThreadPool

Creates a temporary thread when the thread pool is no size limit (you can manually set a maximum), a new run, the task will be the end of the retention period of time (default 60s, you can set up their own). If there is non-stop mission, will the system memory is exhausted

4. ScheduledThreadPool

Similarly FixedThreadPool, except that the scheduled tasks can be performed

5. WorkStealingThreadPool

ForkJoinThreadPool package, more convenient. Thread creation is the guardian of the thread. Each thread has its own task team, a thread task queue is completed, it will go to other thread task queue steal task.

Daemon thread: jvm does not exit, the thread will not quit, even if the main thread has quit.

6. ForkJoinThreadPool

Multithreading is similar to recursion, the amount of computing into smaller calculated and assigned to multiple threads.
Assigned to write their own rules, inheritance ForkJoinTask class, re-compute method.
General will inherit RecursiveAction class, RecursiveTask class is inherited from both ForkJoinTask

Guess you like

Origin www.cnblogs.com/duangL/p/11621729.html