Joining Threads

The three overloaded join() methods block the calling thread until the thread whose join() method is invoked dies.

  public final void join() throws InterruptedException 
  public final void join(long milliseconds) 
   throws InterruptedException 
  public final void join(long milliseconds, int nanoseconds) 
   throws InterruptedException 

For example, t.join() waits for the Thread t to finish before continuing. t.join(1000) waits at most one second for t to finish before continuing.

You would generally use this when one thread depends on another, for example for a file to be read or an image to be loaded from the net.


Previous | Next | Top | Cafe au Lait

Copyright 1997, 1998 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified July 6, 1998