RegularTimePeriod.java (184.108.40.206) has a static Calendar.
I have seem this cause problems if if data is placed
into two TimeSeries concurrently - Dates can get
created with incorrect values and other weirdness
caused by Calendar not being thread safe.
I have worked around the problem by changing the
Calendar to being a ThreadLocal (I guess
Calendar.getInstance returns a new Calendar each time...)
public static final ThreadLocal WORKING_CALENDAR_TL =
new ThreadLocal () ;
public static Calendar getWorkingCalendar()
if (WORKING_CALENDAR_TL.get() == null)
return \(Calendar\) WORKING\_CALENDAR\_TL.get\(\) ;
Access to the calendar in the rest of the class is now
via this getter. It works fine except you will leak
Calendars when threads terminate. A better solution may
be to place the Calendars in an LRUMap with some
reasonable fixed upper limit.
Log in to post a comment.