• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Devu Shah
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • 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.
 
Rick Fortier
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • 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());
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic