E
endymion
Hi,
In a multi-threaded application, I encountered problems with dates being
"reset" to 1970, or being negative when converted into ms since 1970.
I use Calendar to do operations on dates, and as I see no obvious bug in the
code, and as the problem occurs randomly and after a certain time, I was
wondering if that was a multi-threading issue.
So the question is: Is Calendar.getInstance() thread safe?
I did not find a satisfying answer searching the web.
Is there asbolutely no possibility that two (or more) threads calling
Calendar.getInstance() at the same time get the same Calendar object?
In my code I do the following:
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, amount);
[...]
Thanks for your answers.
Christophe B.
In a multi-threaded application, I encountered problems with dates being
"reset" to 1970, or being negative when converted into ms since 1970.
I use Calendar to do operations on dates, and as I see no obvious bug in the
code, and as the problem occurs randomly and after a certain time, I was
wondering if that was a multi-threading issue.
So the question is: Is Calendar.getInstance() thread safe?
I did not find a satisfying answer searching the web.
Is there asbolutely no possibility that two (or more) threads calling
Calendar.getInstance() at the same time get the same Calendar object?
In my code I do the following:
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, amount);
[...]
Thanks for your answers.
Christophe B.