Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Join method

 
Sahil Kapoor
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A snippet 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.

What doe the following line means in above.

A timeout of 0 means wait forever.

Should not it be dont wait ???

Thanks !!!
 
Mike Simmons
Ranch Hand
Posts: 3028
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 316
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tanks Mike Simmons

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

Thanks
Cheers!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic