org.cip4.jdflib.util.thread
Class WaitTimeout<a>

java.lang.Object
  extended by org.cip4.jdflib.util.thread.WaitTimeout<a>
Type Parameters:
a - the returned object data type
All Implemented Interfaces:
Runnable

public abstract class WaitTimeout<a>
extends Object
implements Runnable

abstract class to run uninteruptable stuff in an interruptable thread

Author:
Dr. Rainer Prosi, Heidelberger Druckmaschinen AG 11.12.2008

Field Summary
protected  String baseName
           
 
Constructor Summary
WaitTimeout(int millis)
           
 
Method Summary
 a getWaitedObject()
           
protected abstract  a handle()
          this is the handle routine that may take longer
it should return the expected object when completed
 a peekWaitedObject()
           
 void run()
           
protected  void setup()
          called prior to starting thread, overwrite to initialize in the constructor
 void start()
          start the thread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baseName

protected String baseName
Constructor Detail

WaitTimeout

public WaitTimeout(int millis)
Parameters:
millis - wait timeout in milliseconds
Method Detail

handle

protected abstract a handle()
this is the handle routine that may take longer
it should return the expected object when completed

Returns:
the object that this whole class is about

setup

protected void setup()
called prior to starting thread, overwrite to initialize in the constructor


start

public final void start()
start the thread


run

public final void run()
Specified by:
run in interface Runnable
See Also:
Runnable.run()

getWaitedObject

public final a getWaitedObject()
Returns:
the object that you waited for, null if the timeout is reached

peekWaitedObject

public final a peekWaitedObject()
Returns:
the object that you waited for, if it has been calculated


Copyright © 2013. All Rights Reserved.