Synchronizing on SimpleDateFormat vs. clone

C

Christopher Dean

Does anyone know what are the performance tradeoffs between
synchronizing on static SimpleDateFormat objects (since they are not
thread-safe) vs. creating a static SimpleDateFormat instance and cloning
it every time it needs to be used. I use static instances so the
pattern can be compiled once because this takes time. My gut tells me
the synchronization overhead is greater than the clone but I am not sure
(and don't have a good profiler) so if anyone has any insight....
 
X

X_AWemner_X

Does anyone know what are the performance tradeoffs between
synchronizing on static SimpleDateFormat objects (since they are not
thread-safe) vs. creating a static SimpleDateFormat instance and cloning

You might be interested in the Apache commongs/lang package and
FastDateFormat class in it.
http://jakarta.apache.org/commons/lang/api/index.html
http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/time/Fast
DateFormat.html

It is a tread-safe replacement of original simpleDateFormat class.
 
C

Christopher Dean

Christopher said:
Thanks a bunch. That will get rid of the problem all together.
Oops, FastDateTimeFormat doesn't do parse like
SimpleDateFormat...useless to be now...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top