how to avoid start a same application twice
1 posts in topic
Flat View  Flat View

Posted By:   Albert_Grain
Posted On:   Sunday, November 17, 2002 09:07 PM

I wrote a short java programme and found that it can be started more than 1 times at the same time,ie. there can be multiple instance of my programme running on the same enviroment. How can I avoid this from happening? Thanks

Re: how to avoid start a same application twice

Posted By:   Parag_Bahad  
Posted On:   Monday, November 18, 2002 02:03 AM

Dear Albert,

To avoid this you have to use Sigleton Design Pattarn. This design pattarn gives you the way to avoid the multiple instance of same object.

Singleton object has a static method, a private constructor and a boolean private variable. When you call this staic method this boolean variable get sets to true. And method calls the private constructor to give the object reference.

Your small java program has to be called from this Singleton class to ensure that no more than one object is created.

I hope you have understood.


About | Sitemap | Contact