|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
pt.ua.concurrent.CThread
public class CThread
Thread related static utilities.
This class follows DbC(tm) methodology
(Wikipedia).
Where possible, contracts are implement with native's Java
assert.
Nested Class Summary | |
---|---|
static class |
CThread.TerminationPolicy
|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
CThread()
Constructor of a thread (direct replacement of Thread's constructor). |
|
CThread(CRunnable ctarget,
java.lang.String name)
Constructor of a thread (direct replacement of Thread's constructor). |
|
CThread(java.lang.Runnable target)
Constructor of a thread (direct replacement of Thread's constructor). |
|
CThread(java.lang.Runnable target,
java.lang.String name)
Constructor of a thread (direct replacement of Thread's constructor). |
|
CThread(java.lang.String name)
Constructor of a thread (direct replacement of Thread's constructor). |
|
CThread(java.lang.ThreadGroup group,
CRunnable ctarget)
Constructor of a thread (direct replacement of Thread's constructor). |
|
CThread(java.lang.ThreadGroup group,
CRunnable ctarget,
java.lang.String name)
Constructor of a thread (direct replacement of Thread's constructor). |
|
CThread(java.lang.ThreadGroup group,
CRunnable ctarget,
java.lang.String name,
long stackSize)
Constructor of a thread (direct replacement of Thread's constructor). |
|
CThread(java.lang.ThreadGroup group,
java.lang.Runnable target)
Constructor of a thread (direct replacement of Thread's constructor). |
|
CThread(java.lang.ThreadGroup group,
java.lang.Runnable target,
java.lang.String name)
Constructor of a thread (direct replacement of Thread's constructor). |
|
CThread(java.lang.ThreadGroup group,
java.lang.Runnable target,
java.lang.String name,
long stackSize)
Constructor of a thread (direct replacement of Thread's constructor). |
|
CThread(java.lang.ThreadGroup group,
java.lang.String name)
Constructor of a thread (direct replacement of Thread's constructor). |
Method Summary | |
---|---|
void |
ajoin()
Thread's join replacement, in which: - the checked exception InterruptedException, is replaced by the unchecked exception ThreadInterruptedException. |
void |
ajoin(long millis)
Thread's join replacement, in which: - the checked exception InterruptedException, is replaced by the unchecked exception ThreadInterruptedException. |
void |
ajoin(long millis,
int nanos)
Thread's join replacement, in which: - the checked exception InterruptedException, is replaced by the unchecked exception ThreadInterruptedException. |
void |
arun()
The new thread program method. |
static java.lang.Thread |
currentThread()
Current thread. |
static long |
currentThreadID()
Current thread id. |
long |
elapsedTime()
Elapsed time since startTime . |
static void |
pause(int millis)
A thread safe pause service in which: - the checked exception InterruptedException, is replaced by the unchecked exception ThreadInterruptedException. |
void |
run()
Replacement of default run method to correctly handle exceptions, and also to register thread execution start time. |
void |
setTerminationPolicy(CThread.TerminationPolicy terminationPolicy)
Define the thread's termination policy. |
java.lang.Throwable |
sourceException()
Get the exception responsible for the thread's failure. |
void |
start()
Replacement of default start method (required to properly implement termination policy). |
void |
start(CThread.TerminationPolicy terminationPolicy)
A start method imposing an explicit termination policy. |
boolean |
started()
Was request to start thread issued? |
long |
startTime()
Time instance at which the thread has started execution. |
boolean |
startTimeRegistered()
Has thread start time been registered? |
CThread.TerminationPolicy |
terminationPolicy()
Current CThread object's termination policy. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CThread()
public CThread(java.lang.Runnable target)
target != null
- Runnable object reference
public CThread(java.lang.String name)
name != null
- String object reference
public CThread(java.lang.ThreadGroup group, java.lang.String name)
group != null
- ThreadGroup object referencename != null
- String object reference
public CThread(java.lang.Runnable target, java.lang.String name)
target != null
- Runnable object referencename != null
- String object reference
public CThread(java.lang.ThreadGroup group, java.lang.Runnable target)
group != null
- ThreadGroup object referencetarget != null
- Runnable object reference
public CThread(java.lang.ThreadGroup group, java.lang.Runnable target, java.lang.String name)
group != null
- ThreadGroup object referencetarget != null
- Runnable object referencename != null
- String object reference
public CThread(java.lang.ThreadGroup group, java.lang.Runnable target, java.lang.String name, long stackSize)
group != null
- ThreadGroup object referencetarget != null
- Runnable object referencename != null
- String object referencestackSize > 0L
- positive stack size
public CThread(CRunnable ctarget, java.lang.String name)
target != null
- CRunnable object referencename != null
- String object reference
public CThread(java.lang.ThreadGroup group, CRunnable ctarget)
group != null
- ThreadGroup object referencetarget != null
- CRunnable object reference
public CThread(java.lang.ThreadGroup group, CRunnable ctarget, java.lang.String name)
group != null
- ThreadGroup object referencetarget != null
- CRunnable object referencename != null
- String object reference
public CThread(java.lang.ThreadGroup group, CRunnable ctarget, java.lang.String name, long stackSize)
group != null
- ThreadGroup object referencetarget != null
- CRunnable object referencename != null
- String object referencestackSize > 0L
- positive stack size
Method Detail |
---|
public void setTerminationPolicy(CThread.TerminationPolicy terminationPolicy)
TerminationPolicy.DEBUG
: a thread failure causes a stack dump and the termination of the whole program (default behavior)TerminationPolicy.PROPAGATE
: a thread failure causes the propagation of the failure to the ``parent'' thread (through the interrupt
service)TerminationPolicy.IGNORE
: a thread failure is ignored for the whole programTerminationPolicy.IGNORE_DEBUG
: stack dumped to console, but thread failure is ignored for the whole program
!started()
terminationPolicy
- policy (TerminationPolicy.DEBUG
, TerminationPolicy.PROPAGATE
, TerminationPolicy.IGNORE
, TerminationPolicy.IGNORE_DEBUG
)public CThread.TerminationPolicy terminationPolicy()
public void start(CThread.TerminationPolicy terminationPolicy)
start
method imposing an explicit termination policy.
!started()
terminationPolicy
- policy (TerminationPolicy.DEBUG
, TerminationPolicy.PROPAGATE
, TerminationPolicy.IGNORE
, TerminationPolicy.IGNORE_DEBUG
)setTerminationPolicy
public void start()
start
method (required to properly implement termination policy).
!started()
start
in class java.lang.Thread
public boolean started()
public java.lang.Throwable sourceException()
started() && terminationPolicy() == TerminationPolicy.PROPAGATE
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void arun()
public boolean startTimeRegistered()
public long startTime()
arun
method either through CThread
or CRunnable
.
startTimeRegistered()
public long elapsedTime()
startTime
.
startTimeRegistered()
public void ajoin() throws ThreadInterruptedException
ThreadInterruptedException
public void ajoin(long millis) throws ThreadInterruptedException
millis >= 0
- non negative timeout
millis
- timeout (in milliseconds)
ThreadInterruptedException
public void ajoin(long millis, int nanos) throws ThreadInterruptedException
millis >= 0
- non negative timeoutnanos >= 0
- non negative timeout
millis
- timeout (in milliseconds)nanos
- timeout (in nanoseconds)
ThreadInterruptedException
public static void pause(int millis) throws ThreadInterruptedException
millis >= 0
- non negative pause value
millis
- pause value (in milliseconds)
ThreadInterruptedException
public static java.lang.Thread currentThread()
Thread
objectpublic static long currentThreadID()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |