axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Jellinghaus <r...@unrealities.com>
Subject RE: cvs commit: xml-axis/java/src/org/apache/axis/server AxisServer.java
Date Fri, 15 Jun 2001 22:25:33 GMT
At 05:29 PM 6/15/2001 -0400, Glen Daniels wrote:
>So after a brief spin through that article, will the following work?
...
>class AxisServer {
>  private static AxisServer singleton = new AxisServer();
>  public AxisServer getSingleton()
>  {
>    return singleton;
>  }
>  ...
>}
>
>..would that cause any problems?

>From my reading of the article, yes it might.  getSingleton might be called
(verrry slim chance) after singleton has been assigned but before the
constructor has been called (see the discussion of reordering the
assignment and the constructor).

Why not just

class AxisServer {
	private static AxisServer singleton;
	public static synchronized AxisServer getSingleton () {
		if (singleton == null) {
			singleton = new AxisServer();
		}
		return singleton;
	}
}

They all say that the synchronized technique is fine and unlikely to be a
performance issue....

Cheers,
Rob



Mime
View raw message