Java Executors defaultThreadFactory() Method

The defaultThreadFactory() method of Executors class returns a default thread factory used to create new threads. This factory creates all new threads used by an Executor in the same ThreadGroup. If there is a SecurityManager, it uses the group of System.

Syntax

Parameter

No parameter is passed

Returns

a thread factory

Throw

Not applicable.

Example 1

Test it Now

Output:

Running thread concurrently

Example 2

Test it Now

Output:

Running thread concurrently  ::Sun Mar 17 02:34:38 IST 2019
Running thread concurrently  ::Sun Mar 17 02:34:38 IST 2019
Running thread concurrently  ::Sun Mar 17 02:34:38 IST 2019
Running thread concurrently  ::Sun Mar 17 02:34:38 IST 2019
Running thread concurrently  ::Sun Mar 17 02:34:38 IST 2019
Running thread concurrently  ::Sun Mar 17 02:34:38 IST 2019
Next TopicJava Executors




Latest Courses