Interesting that we had Thread.sleep(long millis, int nanos) since JDK 11, which from the docs makes you assume that if your system supports it you have sub-milliseconds sleeps, but that doesn't work until JDK 21. Until that the minimum sleep is still 1ms (at least on Linux). Just got bitten by it.
Looks like the problem was on POSIX only https://bugs.openjdk.org/browse/JDK-8306660
out of curiosity, what did you use sub-ms sleep for?
which was working fine until it wasn't, and I didn't understood why until I figured I had changed my current jdk
@jjttjj I uploaded a small demo some weeks ago https://www.youtube.com/watch?v=bV-amgLb-2Q in case you are interested
nice, I'll check it out later!
Getting sub millisecond sleeps can be annoying. I don't think most systems support it.
currently it works at least for my purpose on Linux with JDK >= 21
👍
For really accurate sleeps, I ended up doing https://github.com/phronmophobic/clj-libretro/blob/9a155ff4117485171b390c35366bc97e9a57b720/src/com/phronemophobic/clj_libretro/ui.clj#L290. I also had to increase the priority for that thread.
This is on mac osx. Not sure if that is the best approach, but it worked for me.
oh interesting, thanks for sharing
PS: there is also https://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/locks/LockSupport.html#parkNanos(long) the tea-time library uses it
oh, nice, never heard of that before