public class OperationThread extends Thread
EntityResult class.Thread.run() method, and the result
must be stored in an OperationThread variable called res.hasFinished, hasStarted, cancelled , etc. An
implementation example could be public void run() {
hasStarted=true;
// Perform operation. The finish check is done with isAlive()
hasFinished=true;
}
Thread.State, Thread.UncaughtExceptionHandler| Modifier and Type | Field and Description |
|---|---|
protected boolean |
cancelled |
String |
description |
protected boolean |
hasFinished |
protected boolean |
hasStarted |
static String |
OPERATION_CANCELLED |
protected Object |
res |
protected String |
status |
protected Thread |
t |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
OperationThread()
Constructor.
|
OperationThread(String description)
Sets a description to the thread
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Sets the thread status as canceled.
|
String |
getDescription()
Returns the thread description
|
Object |
getResult()
Returns the thread result.
|
String |
getStatus()
Returns the thread status, which is a message referent to the thread
situation.
|
boolean |
hasFinished()
Checks whether the thread has finished.
|
boolean |
hasStarted()
Checks whether the thread has started.
|
boolean |
isCancelled()
Checks whether the thread has been canceled or not
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldprotected Object res
protected boolean cancelled
protected Thread t
protected boolean hasFinished
protected boolean hasStarted
protected String status
public static String OPERATION_CANCELLED
public String description
public OperationThread()
public OperationThread(String description)
description - the thread descriptionpublic String getDescription()
public boolean isCancelled()
public void cancel()
EntityResult configured
for this thread is set as a new EntityResult with operation wrong
and the message OPERATION_CANCELLED.public boolean hasFinished()
public boolean hasStarted()
public Object getResult()
public String getStatus()
Copyright © 2016 Imatia Innovation S.L.. All rights reserved.