Maybe someone has some experience with "realtime" operation of JNI threads?

I have a java app, which calls some C++ code for real time actions. This C++ code creates an independant pthread to do its work, which should run every 20ms.

To do this, it does its business, then calculates how long to sleep for until the next 20ms boundry (sleeping using usleep()). Now, generally this works very nicely, except...