The Artima Developer Community
Sponsored Link

Java Answers Forum
join() ???

1 reply on 1 page. Most recent reply: Jan 7, 2004 8:47 PM by Kishori Sharan

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Honey Maverick

Posts: 8
Nickname: maverick01
Registered: Jan, 2004

join() ??? Posted: Jan 7, 2004 6:47 PM
Reply to this message Reply
Advertisement
Hi,
A program can spawn as many threads as it needs. Here what is the exact and clear meaning of the word "spawn".
And where do we use join()...and what is the difference between join() and stop().


Kishori Sharan

Posts: 211
Nickname: kishori
Registered: Feb, 2002

Re: join() ??? Posted: Jan 7, 2004 8:47 PM
Reply to this message Reply
Suppose t is a thread. When you write

t.join();

then this statement will execute in some thread. Let us call that tread as t1. After the above statement is executed, t1 thread will block until thread t dies.

This kind of statement is used when you do some kind of processing in multiple threads. But the processing at some stage cannot be started untill processing in one thread is done. For example, suppose you have some complex time taking processing to do and you have three parts of processing. The third part can be started only when first two parts are done. So, in one thread yo can write code as:

t1.start() ; // Start first part
t2.start() ; // start second part

// Let us wait for both threads to finish both parts
t1.join();
t2.join();

// Here both pars are done. Assuming your threads t1, t2
//terminated after processing

// Here you can start third stage of your processing

Flat View: This topic has 1 reply on 1 page
Topic: Color in button Previous Topic   Next Topic Topic: I need an example of a query in Java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use