views:

124

answers:

2

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?

+5  A: 

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.

Tom Hawtin - tackline
+1 - there is definitely something a bit weird about an application which has to make frequent calls to `System.currentTimeMillis`.
Stephen C
+1  A: 

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

Alfred
Doesn't answer the question. Also, even according to your quote, System.nanoTime is preferred for interval timing, there is no mention of what the OP is using system time for. Interval timing may not be applicable here.
Tim Bender
Maybe it does not answer the question directly, but I think already others answered the question so I was only providing a tip I read.
Alfred
http://www.techper.net/2008/08/10/systemcurrenttimemillis-systemnanotime-and-their-resolution/timeinMillis has problems with MS windows' granularity
Gene T
Thanks for the link Gene T :). Know we know a little better why currentMillis could be a problem.
Alfred