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

Pavel Rappo via Concurrency-interest <[email protected]>
Newsgroups gmane.comp.java.jsr.166-concurrency
Message-ID <CAChcVumYNrRsh0Z0BSZ0V-YEB-2hqUXbs7=2eyd7hzYWX4pKJg@mail.gmail.com>
> 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.