[concurrency-interest] static initializers and threads

teknokrat teknokrat at yahoo.com
Thu May 25 05:23:35 EDT 2006

This a question on static initializers in Java. The answer may be in the 
language spec but I have not been able to find it. I have the following 

static {
	// do some initialization

class A {

	public A(){}

I have two threads T1, T2 executing

A a = new A();

Assuming T1 enters the static initializer first, what happens to T2? 
Does it block waiting for the initialization to finish before being 
given a reference to a?

Should the static block be synchronized? Are there any conditions under 
which its possible to get a new object a but with the initialization 


More information about the Concurrency-interest mailing list