Reputation: 558
all i want block of code wait for another thread to die where this thread not event thread
Upvotes: 2
Views: 1268
Reputation: 24879
From what I've been able to understand, it looks like you want a block of code to be executed after some thread dies, but you don't want Thread.join() to block the current thread? Then execute the whole thing in a yet another thread:
new Thread() {
public void run() {
someThread.join(); // someThread is the thread that you're waiting to die
// your block of code
}
}.start();
This will execute the code after someThread dies, but won't suspend the current thread.
Upvotes: 0
Reputation: 24271
I believe this is what Thread.join()
method is for:
public final void join() throws InterruptedException
Waits for this thread to die.
Upvotes: 7