File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Join method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Join method " Watch "Join method " New topic

Join method

Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
A snippet from API


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.

What doe the following line means in above.

A timeout of 0 means wait forever.

Should not it be dont wait ???

Thanks !!!

SCJP 6.0 96%

(Connecting the Dots ....)
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3028
Sahil Kapoor wrote:Should not it be dont wait ???

No - the line correctly describes how the join() method actually works.

If you mean that you think that the method should have been designed differently, well, maybe so. Letting 0 signify "forever" seems a little counterintuitive. But what would be the point of calling join(0) if 0 means do not wait? Easier to just not call the method at all, no? Meanwhile, they needed an easy way to say "wait forever", and using zero or negative numbers seems an easy way to do this.

In general, there are a lot of things in Java that could have been done differently, but weren't, and it's possible to spend a lot of time worrying about all these things. But it often isn't very productive or interesting. This issue in particular doesn't seem like a big problem, so I recommend not worrying about it.
Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
Tanks Mike Simmons

I completely agree with your thoughts and last tip too....

I agree. Here's the link:
subject: Join method
It's not a secret anymore!