Package org.h2.util
Class Task
java.lang.Object
org.h2.util.Task
- All Implemented Interfaces:
Runnable
A method call that is executed in a separate thread. If the method throws an
exception, it is wrapped in a RuntimeException.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
call()
The method to be implemented.execute()
Start the thread.Start the thread.get()
Calling this method will set the stop flag and wait until the thread is stopped.Get the exception that was thrown in the call (if any).boolean
Whether the call method has returned (with or without exception).void
join()
Stop the thread and wait until it is no longer running.void
run()
-
Field Details
-
counter
-
stop
public volatile boolean stopA flag indicating the get() method has been called. -
result
The result, if any. -
finished
private volatile boolean finished -
thread
-
ex
-
-
Constructor Details
-
Task
public Task()
-
-
Method Details
-
call
The method to be implemented.- Throws:
Exception
- any exception is wrapped in a RuntimeException
-
run
public void run() -
execute
Start the thread.- Returns:
- this
-
execute
Start the thread.- Parameters:
threadName
- the name of the thread- Returns:
- this
-
get
Calling this method will set the stop flag and wait until the thread is stopped.- Returns:
- the result, or null
- Throws:
RuntimeException
- if an exception in the method call occurs
-
isFinished
public boolean isFinished()Whether the call method has returned (with or without exception).- Returns:
- true if yes
-
getException
Get the exception that was thrown in the call (if any).- Returns:
- the exception or null
-
join
public void join()Stop the thread and wait until it is no longer running. Exceptions are ignored.
-