WaitForMultipleObject feature in Java

Current, I have a method, which will perform lock on

void MyWait()

{

CountDownLatch.aWait

// We can have access to the Stop lock.

}

void MyStop()

{

// Signal Stop lock.

}

This works fine until we need to stop the thread from keep waiting on CountDownLatch, when there is a stop signal. (The method who send stop signal doesn't have access to CountDownLatch, else, the stop method can just directly signal the CountDownLatch)

We would like to have something, "if either CountDownLatch is signaled or Stop lock is signaled", unblock the thread.

Perhaps something like

WaitForMultipleObject(CountDownLatch, StopLock) in method void MyWait()

either one of the object being signaled, the thread will continue execution.

May I know how can I do that in Java?

One of the solution is that I can interrupt the Thread which is halted at line CountDownLatch.aWait. However, I have no access to the Thread which halted at line CountDownLatch.aWait

[1272 byte] By [KwangHooia] at [2007-11-27 7:07:14]
# 1
I just submit an enhancement request on this topic : http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6568991Feel free to vote for the bug :)Message was edited by: KwangHooiMessage was edited by: KwangHooi
KwangHooia at 2007-7-12 18:58:36 > top of Java-index,Core,Core APIs...