Javatpoint Logo
Javatpoint Logo

Java ForkJoinPool commonPool() Method

The commonPool() method of ForkJoinPool class is used to return an instance of common Pool. Its running state is unaffected by the shutdown request.

Syntax:

Parameter:

No parameter is passed.

Returns:

Returns an instance of commonPool.

Throw

Does not throw Exception.

Example 1

Test it Now

Output:

numbers of core available in your processor:4
Common Pool Size before  :0
Common Pool Size after  :3

Example 2

Test it Now

Output:

Thread[main,5,main] computing: 96 to 100
Thread[main,5,main] computing: 93 to 96
Thread[main,5,main] computing: 90 to 93
Thread[main,5,main] computing: 87 to 90
Thread[main,5,main] computing: 84 to 87
Thread[main,5,main] computing: 81 to 84
Thread[main,5,main] computing: 78 to 81
Thread[main,5,main] computing: 75 to 78
Thread[main,5,main] computing: 71 to 75
Thread[main,5,main] computing: 68 to 71
Thread[main,5,main] computing: 65 to 68
Thread[main,5,main] computing: 62 to 65
Thread[main,5,main] computing: 59 to 62
Thread[main,5,main] computing: 56 to 59
Thread[main,5,main] computing: 53 to 56
Thread[main,5,main] computing: 46 to 50
Thread[main,5,main] computing: 43 to 46
Thread[main,5,main] computing: 40 to 43
Thread[main,5,main] computing: 37 to 40
Thread[main,5,main] computing: 34 to 37
Thread[main,5,main] computing: 31 to 34
Thread[main,5,main] computing: 15 to 18
Thread[main,5,main] computing: 12 to 15
Thread[main,5,main] computing: 9 to 12
Thread[main,5,main] computing: 6 to 9
Thread[main,5,main] computing: 3 to 6
Thread[main,5,main] computing: 0 to 3
99





Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials