Thread.Builder.OfPlatform
, Thread.Builder.OfVirtual
Thread
A builder for
Thread
and
ThreadFactory
objects.
Builder
defines methods to set Thread
properties such as the thread name
. This includes properties that would otherwise be inherited. Once set, a Thread
or ThreadFactory
is created with the following methods:
Thread
to run a task. The Thread
's start
method must be invoked to schedule the thread to execute. Thread
to run a task and schedules the thread to execute.ThreadFactory
.A Thread.Builder
is not thread safe. The ThreadFactory
returned by the builder's factory()
method is thread safe.
Unless otherwise specified, passing a null argument to a method in this interface causes a NullPointerException
to be thrown.
Nested Classes
static interface
static interface
Returns a ThreadFactory
to create threads from the current state of the builder.
Sets the thread name to be the concatenation of a string prefix and the string representation of a counter value.
Creates a new Thread
from the current state of the builder and schedules it to execute.
Sets the uncaught exception handler.
Creates a new Thread
from the current state of the builder to run the given task.
Sets the thread name.
name
- thread name
Sets the thread name to be the concatenation of a string prefix and the string representation of a counter value. The counter's initial value is
start
. It is incremented after a
Thread
is created with this builder so that the next thread is named with the new counter value. A
ThreadFactory
created with this builder is seeded with the current value of the counter. The
ThreadFactory
increments its copy of the counter after
newThread
is used to create a
Thread
.
worker-0
" and "worker-1
".
Thread.Builder builder = Thread.ofPlatform().name("worker-", 0);
Thread t1 = builder.start(task1); // name "worker-0"
Thread t2 = builder.start(task2); // name "worker-1"
prefix
- thread name prefix
start
- the starting value of the counter
IllegalArgumentException
- if start is negative
Sets whether the thread inherits the initial values of
inheritable-thread-localvariables from the constructing thread. The default is to inherit.
inherit
- true
to inherit, false
to not inherit
Sets the uncaught exception handler.
ueh
- uncaught exception handler
Creates a new
Thread
from the current state of the builder to run the given task. The
Thread
's
start
method must be invoked to schedule the thread to execute.
task
- the object to run when the thread executes
SecurityException
- if denied by the security manager (See Interaction with security manager when creating platform threads)
Creates a new Thread
from the current state of the builder and schedules it to execute.
task
- the object to run when the thread executes
SecurityException
- if denied by the security manager (See Interaction with security manager when creating platform threads)
Returns a ThreadFactory
to create threads from the current state of the builder. The returned thread factory is safe for use by multiple concurrent threads.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4