Display.sync equivalent for LWJGL3

Since LWJGL3 came out a few years ago, I found, and have been using this for synchronizing my game thread hz:
https://pastebin.com/44bMVmWF

It’s slightly modified from a code-snippit posted on the LWJGL forums.

This code works fantastically, however it burns my laptop’s CPU. I was wondering if there was any good alternatives to achieve the same effect?

Have you tried the code used in LWJGL2?

Works great, Runs much colder. Couldn’t have asked for a better code snippit!

Thanks spasi!

[EDIT]
I made a slight modification to it so that it can be called from multiple threads. This is done so I can sync both my game logic thread, and my rendering thread independently:

https://pastebin.com/YqqzYewx

Note that I changed the getTime() method from using LWJGL2’s high precision timer to using Java’s built-in nanotime. I am not sure whether that is okay, but the results feel fine for both of my threads at any rate.

I feel like this should be more known to developers who use LWJGL3. There isn’t a built-in solution for synchronizing the timing of a thread with LWJGL3, and that may put off some potential developers who get frusturated with using Thread#sleep()

[quote=“orange451,post:3,topic:59611”]
Not everything has to have a static API. Make the mutable state and the sync method non-static, then use a different Sync instance in each thread. The code will be just as simple as before and you won’t have to deal with maps and primitive boxing/unboxing.

[quote=“orange451,post:3,topic:59611”]
LWJGL 3 does C library bindings and nothing else. It’s not a framework or an engine for developing games. If it can be implemented in pure Java, it’s outside the scope of LWJGL.

I absolutely understand the decision to keep LWJGL as a set of bindings and nothing else. I agree with it too.
What I was referring to was some convenient way to let developers know of proper thread syncing! Not having it be apart of the LWJGL API.

I bet there’s a lot of people using LWJGL3 that have never even considered using something other than Thread#sleep().