Question: Reusing CalendarBuilder #774
-
For a server application, I'd like to reuse as much object instances as possible, to improve performance and to reduce GC pressure. From the JavaDocs of But what about its internals? May I reuse |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
So a CalendarBuilder is just a wrapper to the following:
The TimeZoneRegistry is the main reason you can't reuse CalendarBuilder instances, as timezone definitions are only applicable to one input source. But you can create your own builder implementation, for example if you know you won't use any localized timezones. There was another similar question here: #762 |
Beta Was this translation helpful? Give feedback.
CalendarParser and ContentHandler are interfaces, but the default CalendarParser implementation should be thread-safe.
The default ContentHandler is not thread-safe, as it also captures localized timezones in a registry, but you can implement your own. I think it may be difficult to make a ContentHandler completely thread-safe as it maintains state of the calendar as it is being parsed.