开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜