private static final SingletonObj singleton; public SingletonObj () { super (); singleton = this; }
public synchronized SingletonObj getSingleton () { if ( singleton == null ) { new SingletonObj(); } return singleton; } On Fri, 2005-08-05 at 20:11 -0700, Ming Han wrote: > You can use Singleton pattern, but care must be taken. > > For example > > if ( singleton == null ) > { > singleton = new SingletonObj(); > } > > There might be a case where few thread running concurrently on the null > checking, then multiple singleton object will be created more than one. > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]