Top Description Fields Constructors Methods
org.h2.util

public abstract Class Task

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.util.concurrent.atomic.AtomicInteger

A method call that is executed in a separate thread. If the method throws an exception, it is wrapped in a RuntimeException.

Field Summary

Modifier and TypeField and Description
private static final AtomicInteger
private volatile Exception
private volatile boolean
private volatile Object
result

The result, if any.

public volatile boolean
stop

A flag indicating the get() method has been called.

private Thread

Constructor Summary

AccessConstructor and Description
public
Task()

Method Summary

Modifier and TypeMethod and Description
public abstract void
call()

The method to be implemented.

public Task

Returns:

this
execute
()

Start the thread.

public Task

Returns:

this
execute
(String
the name of the thread
threadName
)

Start the thread.

public Object

Returns:

the result, or null
get
()

Calling this method will set the stop flag and wait until the thread is stopped.

public Exception

Returns:

the exception or null
getException
()

Get the exception that was thrown in the call (if any).

public boolean

Returns:

true if yes
isFinished
()

Whether the call method has returned (with or without exception).

public void
join()

Stop the thread and wait until it is no longer running.

public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

counterback to summary
private static final AtomicInteger counter
exback to summary
private volatile Exception ex
finishedback to summary
private volatile boolean finished
resultback to summary
private volatile Object result

The result, if any.

stopback to summary
public volatile boolean stop

A flag indicating the get() method has been called.

threadback to summary
private Thread thread

Constructor Detail

Taskback to summary
public Task()

Method Detail

callback to summary
public abstract void call() throws Exception

The method to be implemented.

Exceptions
Exception:
any exception is wrapped in a RuntimeException
executeback to summary
public Task execute()

Start the thread.

Returns:Task

this

executeback to summary
public Task execute(String threadName)

Start the thread.

Parameters
threadName:String

the name of the thread

Returns:Task

this

getback to summary
public Object get()

Calling this method will set the stop flag and wait until the thread is stopped.

Returns:Object

the result, or null

Exceptions
RuntimeException:
if an exception in the method call occurs
getExceptionback to summary
public Exception getException()

Get the exception that was thrown in the call (if any).

Returns:Exception

the exception or null

isFinishedback to summary
public boolean isFinished()

Whether the call method has returned (with or without exception).

Returns:boolean

true if yes

joinback to summary
public void join()

Stop the thread and wait until it is no longer running. Exceptions are ignored.

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override