• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Regsrding the use of singleton method in our assignment.....

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi everybody,
i have one confusing question.
I know what is an Singleton pattern.
But I want to know where do we implement it in our assignment.?
If we are not using it what difference does it make in the apllication working.
(Why i am asking... is because, already methods are syncronised and also we all are implementing lock-unlock mechnism ...then what would be specieal function of Singleton? )
Please explain me if i am wrong some where.
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The singleton pattern is when you want to make sure that you only have one copy of something. So if you are trying to maintain a list of current locks on the database, then that would be a good place to use it. You dont want each thread to create its own copy of the locks do you?
Then you must synchronize the collection you are using. I used as HashMap to keep the list of current locks.
locks = Collections.synchronizedMap(new HashMap());
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic