ForkJoinPool.ForkJoinWorkerThreadFactory
Stay organized with collections
Save and categorize content based on your preferences.
Factory for creating new ForkJoinWorkerThread
s.
A ForkJoinWorkerThreadFactory
must be defined and used
for ForkJoinWorkerThread
subclasses that extend base
functionality or initialize threads with different contexts.
Public Methods
Returns a new worker thread operating in the given pool.
Parameters
pool |
the pool this thread works in |
Returns
- the new worker thread, or
null
if the request
to create a thread is rejected
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003eForkJoinPool.ForkJoinWorkerThreadFactory\u003c/code\u003e is used to create new \u003ccode\u003eForkJoinWorkerThread\u003c/code\u003es, especially for customized subclasses.\u003c/p\u003e\n"],["\u003cp\u003eIt provides a single method, \u003ccode\u003enewThread\u003c/code\u003e, which generates a new worker thread for a given \u003ccode\u003eForkJoinPool\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003enewThread\u003c/code\u003e method can return \u003ccode\u003enull\u003c/code\u003e if the thread creation request is rejected or throw a \u003ccode\u003eNullPointerException\u003c/code\u003e if the provided pool is null.\u003c/p\u003e\n"]]],[],null,["public static interface **ForkJoinPool.ForkJoinWorkerThreadFactory** \nFactory for creating new [ForkJoinWorkerThread](../../../../reference/java/util/concurrent/ForkJoinWorkerThread.html)s.\nA `ForkJoinWorkerThreadFactory` must be defined and used\nfor `ForkJoinWorkerThread` subclasses that extend base\nfunctionality or initialize threads with different contexts. \n\nPublic Method Summary\n\n|-------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [ForkJoinWorkerThread](../../../../reference/java/util/concurrent/ForkJoinWorkerThread.html) | [newThread](../../../../reference/java/util/concurrent/ForkJoinPool.ForkJoinWorkerThreadFactory.html#newThread(java.util.concurrent.ForkJoinPool))([ForkJoinPool](../../../../reference/java/util/concurrent/ForkJoinPool.html) pool) Returns a new worker thread operating in the given pool. |\n\nPublic Methods \n\npublic abstract [ForkJoinWorkerThread](../../../../reference/java/util/concurrent/ForkJoinWorkerThread.html)\n**newThread**\n([ForkJoinPool](../../../../reference/java/util/concurrent/ForkJoinPool.html) pool) \nReturns a new worker thread operating in the given pool. \n\nParameters\n\n| pool | the pool this thread works in |\n|------|-------------------------------|\n\nReturns\n\n- the new worker thread, or `null` if the request to create a thread is rejected \n\nThrows\n\n| [NullPointerException](../../../../reference/java/lang/NullPointerException.html) | if the pool is null |\n|-----------------------------------------------------------------------------------|---------------------|"]]