RFR: 8305092: Improve Thread.sleep(millis, nanos) for sub-millisecond granularity [v7]
Alan Bateman
alanb at openjdk.org
Fri Apr 21 07:15:53 UTC 2023
On Thu, 20 Apr 2023 08:12:50 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/Thread.java line 1:
>>
>>> 1: /*
>>
>> Why doesn't `Thread.sleep(long millis)` simply call `Thread.sleep(millis, 0)` instead of duplicating most of the code?
>
> That would change the stack depth, for which some tests are sensitive. https://github.com/openjdk/jdk/pull/13225#issuecomment-1514461529. I think merging `sleep` implementations is something to do in a targeted cleanup, which would handle those test updates too.
One this change is in, I'd like to do some refactoring and have a private sleepNanos that the 3 sleep methods call with the nanos value. That will change the stack depth so it means a few tests need update, but we know what they are now.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13225#discussion_r1173391987
More information about the core-libs-dev
mailing list