Java Executor privilegedThreadFactory() MethodThe 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. SyntaxParameterNo parameter is passed. Returnsa thread factory ThrowsAccessControlException Example 1Test it NowOutput: Running thread concurrently Example 2Test it NowOutput: 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 |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India