Re: More accurate wording for java.util.concurrent.TimeUnit.sleep

David Holmes via Concurrency-interest <[email protected]>
Newsgroups gmane.comp.java.jsr.166-concurrency
Message-ID <[email protected]>
Hi Pavel,

Yes my bad. Timeunit itself takes care of the <= 0 behaviour.

David

> -----Original Message-----
> From: Pavel Rappo
> Sent: Saturday, August 31, 2019 1:09 AM
> To: [email protected]
> Cc: Thorsten Goetzke <[email protected]>; David Holmes <[email protected]>; concurrency-interest <concurrency-
> [email protected]>
> Subject: Re: [concurrency-interest] More accurate wording for java.util.concurrent.TimeUnit.sleep
> 
> > On Fri, Aug 30, 2019 at 2:25 PM David Holmes via Concurrency-interest <[email protected]> wrote:
> >
> > <snip>
> >
> > BTW the claim that a sleep time of zero does not sleep at all is also not quite accurate - it's implemented as a "yield" so may or may
> not actually result in the thread going off CPU. As Doug used to put it sleep(0) means "sleep for at least no time".
> 
> If I understand this correctly, TimeUnit.sleep does not try to specify how Thread.sleep behaves. Instead, TimeUnit.sleep builds on top
> of Thread.sleep's behavior by saying that if TimeUnit.sleep(timeout) is called with timeout <= 0, then the Thread.sleep method is not
> called at all. But I can definitely see how it might be confusing given that TimeUnit.sleep is designed as "a convenience method that
> converts time arguments into the form required by the {@code Thread.sleep} method."

_______________________________________________
Concurrency-interest mailing list
[email protected]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.