If the thread throws an exception during its lifetime, it will be caught by this class and stored to be retrieved after it has been joined.
Subclasses can override runImpl() instead of run() to execute their work.
The class will catch all exceptions that occur in its run method, and will rethrow any exceptions that are not safe to recover from. Safely recoverable exceptions are: StackOverflowError, OutOfMemoryError, LinkageError, ServiceConfigurationError, AssertionError, Exception. Other Throwables and Errors will be thrown from the run() method of the thread. All exceptions are going to be stored for later retrieval nonetheless.
public | Allocates a new Thread object. |
public | ExceptionThread( Allocates a new Thread object. |
public | ExceptionThread( Allocates a new Thread object. |
public | ExceptionThread( Allocates a new Thread object. |
public | ExceptionThread( Allocates a new Thread object. |
public | ExceptionThread( Allocates a new Thread object so that it has target
as its run object, has the specified name as its name,
and belongs to the thread group referred to by group . |
public | ExceptionThread( Allocates a new Thread object so that it has target
as its run object, has the specified name as its name,
and belongs to the thread group referred to by group , and has
the specified stack size. |
public | ExceptionThread( Allocates a new Thread object. |
public | ExceptionThread( Allocates a new Thread object. |
public | ExceptionThread( Allocates a new Thread object so that it has target
as its run object, has the specified name as its name,
and belongs to the thread group referred to by group . |
public | ExceptionThread( Allocates a new Thread object so that it has target
as its run object, has the specified name as its name,
and belongs to the thread group referred to by group , and has
the specified stack size. |
public | ExceptionThread( Allocates a new Thread object. |
public | ExceptionThread( Allocates a new Thread object. |
public Throwable | Gets the exception thrown by the thread. |
public Throwable | |
public Throwable | |
public void | |
public final void | run() If this thread was constructed using a separate
Runnable run object, then that
Runnable object's run method is called;
otherwise, this method does nothing and returns. |
protected void | runImpl() Runs the thread. |
public Throwable | Takes the exception from the thread object. |
From: Thread blockedOn, checkAccess, clone, countStackFrames, destroy, getContextClassLoader, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, interrupt, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, setUncaughtExceptionHandler, start, stop, stop, suspend, toString |
From: Object |
Thread
object. This constructor has the same
effect as Thread
(null, target, gname)
, where gname
is a newly generated
name. Automatically generated names are of the form
"Thread-"+
n, where n is an integer.run
method is invoked when this thread
is started. If null
, this classes run
method does
nothing.Thread
object. This constructor has the same
effect as Thread
(group, target, gname)
,where gname
is a newly generated
name. Automatically generated names are of the form
"Thread-"+
n, where n is an integer.null
and there is a security
manager, the group is determined by SecurityManager.getThreadGroup().
If there is not a security manager or
SecurityManager.getThreadGroup()
returns null
, the group
is set to the current thread's thread group.run
method is invoked when this thread
is started. If null
, this thread's run method is invoked.Thread
object so that it has target
as its run object, has the specified name
as its name,
and belongs to the thread group referred to by group
. If there is a security manager, its checkAccess method is invoked with the ThreadGroup as its argument.
In addition, its checkPermission
method is invoked with
the RuntimePermission("enableContextClassLoaderOverride")
permission when invoked directly or indirectly by the constructor
of a subclass which overrides the getContextClassLoader
or setContextClassLoader
methods.
The priority of the newly created thread is set equal to the priority of the thread creating it, that is, the currently running thread. The method setPriority may be used to change the priority to a new value.
The newly created thread is initially marked as being a daemon thread if and only if the thread creating it is currently marked as a daemon thread. The method setDaemon may be used to change whether or not a thread is a daemon.
null
and there is a security
manager, the group is determined by SecurityManager.getThreadGroup().
If there is not a security manager or
SecurityManager.getThreadGroup()
returns null
, the group
is set to the current thread's thread group.run
method is invoked when this thread
is started. If null
, this thread's run method is invoked.Thread
object so that it has target
as its run object, has the specified name
as its name,
and belongs to the thread group referred to by group
, and has
the specified stack size. This constructor is identical to Thread(stackSize
parameter, if any, is highly platform dependent.
On some platforms, specifying a higher value for the
stackSize
parameter may allow a thread to achieve greater
recursion depth before throwing a StackOverflowError.
Similarly, specifying a lower value may allow a greater number of
threads to exist concurrently without throwing an OutOfMemoryError (or other internal error). The details of
the relationship between the value of the stackSize parameter
and the maximum recursion depth and concurrency level are
platform-dependent. On some platforms, the value of the
stackSize
parameter may have no effect whatsoever.
The virtual machine is free to treat the stackSize
parameter as a suggestion. If the specified value is unreasonably low
for the platform, the virtual machine may instead use some
platform-specific minimum value; if the specified value is unreasonably
high, the virtual machine may instead use some platform-specific
maximum. Likewise, the virtual machine is free to round the specified
value up or down as it sees fit (or to ignore it completely).
Specifying a value of zero for the stackSize
parameter will
cause this constructor to behave exactly like the
Thread(ThreadGroup, Runnable, String)
constructor.
Due to the platform-dependent nature of the behavior of this constructor, extreme care should be exercised in its use. The thread stack size necessary to perform a given computation will likely vary from one JRE implementation to another. In light of this variation, careful tuning of the stack size parameter may be required, and the tuning may need to be repeated for each JRE implementation on which an application is to run.
Implementation note: Java platform implementers are encouraged to
document their implementation's behavior with respect to the
stackSize
parameter.
null
and there is a security
manager, the group is determined by SecurityManager.getThreadGroup().
If there is not a security manager or
SecurityManager.getThreadGroup()
returns null
, the group
is set to the current thread's thread group.run
method is invoked when this thread
is started. If null
, this thread's run method is invoked.null
and there is a security
manager, the group is determined by SecurityManager.getThreadGroup().
If there is not a security manager or
SecurityManager.getThreadGroup()
returns null
, the group
is set to the current thread's thread group.Thread
object. This constructor has the same
effect as Thread
(group, target, gname)
,where gname
is a newly generated
name. Automatically generated names are of the form
"Thread-"+
n, where n is an integer.null
and there is a security
manager, the group is determined by SecurityManager.getThreadGroup().
If there is not a security manager or
SecurityManager.getThreadGroup()
returns null
, the group
is set to the current thread's thread group.run
method is invoked when this thread
is started. If null
, this thread's run method is invoked.Thread
object so that it has target
as its run object, has the specified name
as its name,
and belongs to the thread group referred to by group
. If there is a security manager, its checkAccess method is invoked with the ThreadGroup as its argument.
In addition, its checkPermission
method is invoked with
the RuntimePermission("enableContextClassLoaderOverride")
permission when invoked directly or indirectly by the constructor
of a subclass which overrides the getContextClassLoader
or setContextClassLoader
methods.
The priority of the newly created thread is set equal to the priority of the thread creating it, that is, the currently running thread. The method setPriority may be used to change the priority to a new value.
The newly created thread is initially marked as being a daemon thread if and only if the thread creating it is currently marked as a daemon thread. The method setDaemon may be used to change whether or not a thread is a daemon.
null
and there is a security
manager, the group is determined by SecurityManager.getThreadGroup().
If there is not a security manager or
SecurityManager.getThreadGroup()
returns null
, the group
is set to the current thread's thread group.run
method is invoked when this thread
is started. If null
, this thread's run method is invoked.Thread
object so that it has target
as its run object, has the specified name
as its name,
and belongs to the thread group referred to by group
, and has
the specified stack size. This constructor is identical to Thread(stackSize
parameter, if any, is highly platform dependent.
On some platforms, specifying a higher value for the
stackSize
parameter may allow a thread to achieve greater
recursion depth before throwing a StackOverflowError.
Similarly, specifying a lower value may allow a greater number of
threads to exist concurrently without throwing an OutOfMemoryError (or other internal error). The details of
the relationship between the value of the stackSize parameter
and the maximum recursion depth and concurrency level are
platform-dependent. On some platforms, the value of the
stackSize
parameter may have no effect whatsoever.
The virtual machine is free to treat the stackSize
parameter as a suggestion. If the specified value is unreasonably low
for the platform, the virtual machine may instead use some
platform-specific minimum value; if the specified value is unreasonably
high, the virtual machine may instead use some platform-specific
maximum. Likewise, the virtual machine is free to round the specified
value up or down as it sees fit (or to ignore it completely).
Specifying a value of zero for the stackSize
parameter will
cause this constructor to behave exactly like the
Thread(ThreadGroup, Runnable, String)
constructor.
Due to the platform-dependent nature of the behavior of this constructor, extreme care should be exercised in its use. The thread stack size necessary to perform a given computation will likely vary from one JRE implementation to another. In light of this variation, careful tuning of the stack size parameter may be required, and the tuning may need to be repeated for each JRE implementation on which an application is to run.
Implementation note: Java platform implementers are encouraged to
document their implementation's behavior with respect to the
stackSize
parameter.
null
and there is a security
manager, the group is determined by SecurityManager.getThreadGroup().
If there is not a security manager or
SecurityManager.getThreadGroup()
returns null
, the group
is set to the current thread's thread group.run
method is invoked when this thread
is started. If null
, this thread's run method is invoked.Thread
object. This constructor has the same
effect as Thread
(null, target, gname)
, where gname
is a newly generated
name. Automatically generated names are of the form
"Thread-"+
n, where n is an integer.run
method is invoked when this thread
is started. If null
, this classes run
method does
nothing.Callers should make sure that the thread is finished before calling this.
null
if none was thrown, or the thread hasn't finished yet.null
if none.null
if none.Runnable
run object, then that
Runnable
object's run
method is called;
otherwise, this method does nothing and returns.
Subclasses of Thread
should override this method.
Subclasses can override this method instead of run(), and any exception thrown by this method will be stored to retrieve when the thread is joined.
The default implementation calls super.run().
Callers should make sure that the thread is finished before calling this.
This method will check if the thread has thrown an exception, and will atomically exchange it to a
null
internally. Further calls to getException() or takeException() will return
null
.
null
if none was thrown, or the thread hasn't finished yet.