Name: vi73552 Date: 04/14/99
1) access java.text.SimpleDateFormat.format(java.util.Date) from
multiple threads
5) looking at the source code of the classes it is obvious
that this is not going to work for multiple threads, because the
method format() manipulates object members.
In my professional opinion the format() method should leave the
state of the DateFormat object unchanged. Members must only be
accessed read-only. In C++ you would declare the method const.
I think there is a mismatch between the semantics the class
maintains to the outside and the way it is implemented
internally. Maintaining a DateFormat object per thread is
unnecessary overhead, and in our case [a system wide logging
utility accessed from multiple clients] it's unreasonable.
It would be very efficient to set up an immutable DateFormat
object once, and then access it *unsynchronized* from many
threads, each of which getting their dates formatted
(Review ID: 56578)
======================================================================
- duplicates
-
JDK-4093418 DateFormat is not threadsafe
-
- Closed
-