Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Single object versus multiple

 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may be obvious but still would like to know.

Please let me know if and whether there would be a performance penaltly if I had an object of class A that had a method foo() which services many many requests versus having multiple instances of the object servicing individual requests. For the discussion, lets assume that the class that represents foo() does not have any properties or problems or synchronization issues. I see that this can be made as a static method in a static class but was wondering if having a single object servicing multiple requests versus having multiple objects servicing multiple requests have any benefits one way or the other.

Thanks..
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If there is no synchronization, then no, it doesn't matter how many threads are accessing an object simultaneously, there will be no performance penalty, and no advantage to using multiple objects. Of course, as soon as there is synchronization, it's a different story, and then multiple server objects will perform better than one.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic