Performance bottleneck in concurrent calls to System.currentTimeInMillis()
I suspect that calls from separate threads (>15) are having a negative effect on performance. Is there a better开发者_如何学运维 way to get at the system time in concurrent applications?
If it really is a problem, you can have a background thread store the current time in a volatile
. Or just call it less often.
Just a little tip:
I read from google engineers and other programmers that it is better to use System.nanotime. For example joshua bloch
For interval timing, always use System.nanoTime in preference to System.currentTimeMillis
精彩评论