[concurrency-interest] Re: SynchronizedLong vs. other locks

Aleksey Gureev spyromus at noizeramp.com
Fri Jul 8 10:08:31 EDT 2005


Dawid,

> Not really, since you have "read-modify-write" operation; you need the 
> lock if you want to keep it in a shared variable. But why not just do:
> 
> private static final long DAY = 24*60*60*1000;
> 
> private static long getTomorrowTime() {
>     return (((System.currentTimeMillis() + DAY)/DAY)*DAY;
> }
> 
> I bet this will be much faster than synchronization.

:) You forget about the time zones.

Thanks for advice!

Aleksey



More information about the Concurrency-interest mailing list