org.locomotive.util
Class BlockLock

java.lang.Object
  |
  +--org.locomotive.util.BlockLock

public class BlockLock
extends java.lang.Object

BlockLock - allows one thread to hold and release another efficiently. Warning: having multiple threads call block could result in bizzarre behaviour. Calling block after unblock will have no effect and return immediately, since a BlockLock is only good for a one time usage.


Constructor Summary
BlockLock()
          creates a new BlockLock.
 
Method Summary
 void block()
          thread that wants to block calls this
 boolean blockForTime(long time)
          blocks for a certain maximum time period.
 void unblock()
          unblocks the thread that called block()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockLock

public BlockLock()
creates a new BlockLock. The constructor itself is non blocking.
Method Detail

block

public void block()
thread that wants to block calls this

blockForTime

public boolean blockForTime(long time)
blocks for a certain maximum time period. Will return true if the block timed out.
Parameters:
time - - the time in milliseconds to wait before timing out

unblock

public void unblock()
unblocks the thread that called block()