> I am facing problem in Threads in java. I have studied threads and know
> the theory of it. But I just cant get started. It would be great if I
> can get some sample codes showing the use of wait(), notify(), sleep()
> . The code should have a number of threads (say 2-3) and each thread is
> running.
>> I am facing problem in Threads in java. I have studied threads and know
>> the theory of it. But I just cant get started. It would be great if I
[quoted text clipped - 6 lines]
>
> start, join and sleep are easy to use.
No. Don't use sleep. Even as a joke. You might think your code works
fine with sleep, but not even the Java library code does.
> If you need slightly more advanced stuff then use
> the new java.util.concurrent package instead of doing
> it yourself.
If you possibly can.
If you want to learn about threads in Java 1.5+, I suggest starting with
"Java Concurrency in Practice" by Brian Goetz, Joshua Bloch, Joseph
Bowbeer, Doug Lea, David Holmes, Tim Peierls.
http://www.amazon.co.uk/dp/0321349601/ref=sr_11_1/202-5739469-5649426
Tom Hawtin
Arne Vajhøj - 14 Oct 2006 17:31 GMT
> No. Don't use sleep. Even as a joke. You might think your code works
> fine with sleep, but not even the Java library code does.
I am not quite clear what you mean.
Are you saying that sleep has a bug in all Java implementations
(SUN, IBM, BEA etc.) ?
Or are you saying that can read the contents of my hard drive
by telepathy and see that my usage of sleep does not match the
documented semantics of sleep ?
Or ?
Arne