Javatpoint Logo
Javatpoint Logo

Java Executor privilegedThreadFactory() Method

The privilegedThreadFactory() method of Executors class returns a thread factory used to create new threads that have the same permissions as the current thread. This factory creates threads with the same settings as defaultThreadFactory(), additionally setting the AccessControlContext and contextClassLoader of new threads to be the same as the thread invoking this privilegedThreadFactory method.

Syntax

Parameter

No parameter is passed.

Returns

a thread factory

Throws

AccessControlException

Example 1

Test it Now

Output:

Running thread concurrently

Example 2

Test it Now

Output:

Running thread concurrently  ::Sun Mar 17 03:24:04 IST 2019
Running thread concurrently  ::Sun Mar 17 03:24:04 IST 2019
Running thread concurrently  ::Sun Mar 17 03:24:04 IST 2019
Running thread concurrently  ::Sun Mar 17 03:24:04 IST 2019
Running thread concurrently  ::Sun Mar 17 03:24:04 IST 2019
Running thread concurrently  ::Sun Mar 17 03:24:04 IST 2019
Next TopicJava Executors





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA