RFR: 8305092: Improve Thread.sleep(millis, nanos) for sub-millisecond granularity [v2]
Aleksey Shipilev
shade at openjdk.org
Tue Apr 18 17:59:12 UTC 2023
On Thu, 30 Mar 2023 01:26:36 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> Aleksey Shipilev has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains ten commits:
>>
>> - Merge branch 'master' into JDK-83050920-thread-sleep-subms
>> - Work
>> - Draft work
>> - Merge branch 'master' into JDK-83050920-thread-sleep-subms
>> - Merge branch 'master' into JDK-83050920-thread-sleep-subms
>> - More fixes
>> - Fix Windows yet again
>> - Helper method should be inline, not static
>> - Work
>
> src/hotspot/share/runtime/javaThread.cpp line 1981:
>
>> 1979: }
>> 1980:
>> 1981: bool JavaThread::sleep(jlong millis, jint nanos) {
>
> You don't need the overloads at this level - the incoming call should always have millis and nanos, even if nanos is zero.
I think the distinction between millis and nanos makes our life unnecessarily hard here. `jlong nanos` is already quite big for practical uses, and so we can simplify this code by only passing `nanos` around. In new revision, I still do two overloads to avoid "unit" mistakes.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13225#discussion_r1170390101
More information about the core-libs-dev
mailing list