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

Dawid Kurzyniec dawidk at mathcs.emory.edu
Fri Jul 8 10:49:14 EDT 2005


Tim Peierls wrote:

> Tim Peierls wrote:
>
>> Dawid Kurzyniec wrote:
>>
>>> private static final long DAY = 24*60*60*1000;
>>>
>>> private static long getTomorrowTime() {
>>>    return (((System.currentTimeMillis() + DAY)/DAY)*DAY;
>>> }
>>
>>
>>
>> Does this deal with leap seconds properly?
>
>
> Answering my own question: No, it doesn't. The program below produces 
> this output on my machine (today):
>
> t1 = 1120881600000
> t2 = 1120867200000
>
> a difference of 4 minutes. (Hmm, why four minutes? Only 23 leap 
> seconds have been inserted since the epoch.)
>
It's 4 *hours*, it probably accounts for the difference in time zone. I 
still am trying to convince myself that my second version (with the 
offset) is correct...

Looking at the source code of the GregorianCalendar, it doesn't seem 
that it has a concept of leap seconds...

Regards,
Dawid



More information about the Concurrency-interest mailing list