开发者

Performance bottleneck in concurrent calls to System.currentTimeInMillis()

开发者 https://www.devze.com 2022-12-25 01:42 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消