> The outcome is bit out of my anticipation:
> What happened to create the sentence "sleep interrupted!"
You called m.interrupt() from main(), which resulted in an exception
in thread "m", currently sleeping. The exception contained the message
which you then printed in the catch block in run().
/gordon
--
Jack Dowson - 04 May 2007 14:14 GMT
Gordon Beaton 写道:
>> The outcome is bit out of my anticipation:
>> What happened to create the sentence "sleep interrupted!"
[quoted text clipped - 4 lines]
>
> /gordon
So when we interrupt a sleep thread it will become runnable!
Right?
Thank you!
Jack Dowson - 04 May 2007 14:17 GMT
Gordon Beaton 写道:
>> The outcome is bit out of my anticipation:
>> What happened to create the sentence "sleep interrupted!"
[quoted text clipped - 4 lines]
>
> /gordon
So that means if we interrupt a sleep thread then it will become
runnable,right?
Thank you!
Patricia Shanahan - 04 May 2007 14:24 GMT
> Gordon Beaton дµÀ:
>>> The outcome is bit out of my anticipation:
[quoted text clipped - 7 lines]
> So that means if we interrupt a sleep thread then it will become
> runnable,right?
Yes, an interrupt ends a sleep etc.
If you want to be sure to sleep for a specified time regardless of
interrupt, you need to keep track of when the sleep is due to end, and
put the sleep in a while loop.
However, it is more usual to send an interrupt to a thread when it
should stop what it is currently doing and do something else.
Patricia
Jack Dowson - 04 May 2007 14:28 GMT
Patricia Shanahan 写道:
>> Gordon Beaton дµÀ:
>>>> The outcome is bit out of my anticipation:
[quoted text clipped - 18 lines]
>
> Patricia
Thank you so much!