File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubts regarding join from dans mock

 
anjali desh
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a question from dan's topic wise test

g]Thread.join will return immediately if the timeout value is zero
h] A timeout of zero will allow Thread.join to wait forever if necessary .

According to my understanding g] should be true and h] should be false.But the answer is other way round.
The maximum time limit to wait for the death of the referenced thread can be specified in milliseconds by an argument. Now if time-out is 0 secs then shouldnt g be correct.
Maybe there is something wrong in my understanding..Plz help me clarify this concept.

Anjali
[ October 04, 2005: Message edited by: Barry Gaunt ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you read the API for the Thread join method? If you have not, then I suggest that you do so. If you need help on finding the API or the appropriate part of it please let us know, and we will direct you to it.
 
anjali desh
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have gone through it Barry...But will take your suggestion and read it again.Maybe I missed something or mis-interpreted something.
Thanks,
Anjali
[ October 05, 2005: Message edited by: anjali desh ]
 
Roja Rani
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following is from API

join
public final void join(long millis)
throws InterruptedException
Waits at most millis milliseconds for this thread to die. A timeout of 0 means to wait forever.
 
anjali desh
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will time-out of 0 be represented as..
t2.join(0)?
Wont this mean wait atmost 0 seconds? So wont thread t1 return to the runnable state immediately?
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, because: A timeout of 0 means to wait forever. join(0) will wait forever, by definition it is an exception to the rule.

Object.wait also waits forever if the argument is 0.

(Sorry Anjali about the emphasis on reading the API. I did it because some posters never do take look at it when they have a doubt.)
 
anjali desh
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Barry..This question was troubling me since morning and I was finding it hard to concentrate on other topics..especially as I have got my exam scheduled on saturday and threads is one of the most dreaded topics!!
And you definately dont have to say sorry!!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic