[concurrency-interest] Thread safety when loading and linking classes

Péter Kovács peter.kovacs.1.0rc at gmail.com
Wed Apr 22 11:10:15 EDT 2009


Hi,

Is the Class.forName(String) call thread-safe? Must the underlying
ClassLoader instances be thread safe or is their thread-safety
guaranteed "automagically" by the JVM? If ClassLoader instances must
be thread-safe, is the default application class loader known to be
thread-safe? (Based on the reference to JLS 12.4.2 in JCIP 3.5.3,
there appears to be fairly strong guarantees about the thread-safety
of class initialization, but it is not immediately clear to me whether
similar guarantees can be assumed about the loading and liking phase
as well.)

(We're having a rare random problem and [short of any better, more
realistic candidate] Class.forName(String) has come under suspicion.)

Thanks
Peter


More information about the Concurrency-interest mailing list