public final class

ThreadEx

extends Thread
java.lang.Object
   ↳ java.lang.Thread
     ↳ com.pnfsoftware.jeb.util.concurrent.ThreadEx<V>

Class Overview

An extension of Thread supporting the execution of Callable as well as Runnable. Two additional get() and get(timeout) methods, not unlike Future's get(), allow querying and waiting for the execution result. When executing a Runnable, get() will always return null. An exception occurring during the execution of the thread is collected and re-thrown inside an ExecutionException object.

Summary

[Expand]
Inherited Constants
From class java.lang.Thread
Public Constructors
ThreadEx(Runnable runnable)
ThreadEx(Callable<V> callable)
Public Methods
V get(long millis)
Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.
V get()
Waits if necessary for the computation to complete, and then retrieves its result.
final void run()
[Expand]
Inherited Methods
From class java.lang.Thread
From class java.lang.Object
From interface java.lang.Runnable

Public Constructors

public ThreadEx (Runnable runnable)

public ThreadEx (Callable<V> callable)

Public Methods

public V get (long millis)

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

Parameters
millis the maximum time to wait, in milliseconds; 0 means wait forever
Returns
  • the computed result; always null for a Runnable
Throws
ExecutionException if the computation threw an exception
InterruptedException if the current thread was interrupted while waiting
TimeoutException if the wait timed out

public V get ()

Waits if necessary for the computation to complete, and then retrieves its result.

Returns
  • the computed result; always null for a Runnable
Throws
ExecutionException if the computation threw an exception
InterruptedException if the current thread was interrupted while waiting

public final void run ()