This content has been marked as final. Show 4 replies
xxAS wrote:Any of the general Java programming forums, or the concurrency forum. But I'll drag into real-time relevance :)
Well I know that it isn't any realtime system, but I didn't know where to put this article.
This error happens only sometimes, but cpu-usage is still less than 15%.You're executing on a time-sharing scheduler that operates across all threads in the system, including system tasks. Your Java threads can be forced off CPU at any time and for a length of time that depends on the complete system load at that time. Any system tasks have higher priority than your Java threads, so it doesn't take much activity to displace the JVM. In a real-time JVM you can assign priorities that allow you to be as high-as or higher than system tasks so you get greater scheduling control and won't be pushed off CPU (unless you're blocking on shared resources).
By the way, I just looked a bit closer at your little experiment and I see from all the zeroes and 296 values that you must be on Windows: on Windows the time reported by currentTimeMillis() is only updated every 10ms - hence the bunch of zeroes making it look like it takes "no time" between calls (and the same with the bunch of 296), and if you continue this experiment you'll probably see that you get delayed periodically..