• 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

Objects in a multi threaded environment. Code segments?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When a class is instantiated by multiple threads does each object of the class share the space of the methods or the class body.
What I am trying to find out is whether there exists a "code segment" for each of these objects or one that is common for all.
The problem I am trying to highlight to a co-worker is that a 5000 line class file (say x) being called by multiple intances of multiple servlets may not be the optimal way to design the system. Will each servlet instance have a one chunky object of x.
The class x can be broken up into multiple classes since the functionality for each servlet in the class is different. I feel that this is more efficient as well as well as more organized.
The argument offered is that the "code segment" of the 5000 line file is the same for all objects, but the "data segment" is different for each. Therefore it is justified !
I haven't come across the term "Code segment" (in program memory) with reference to the Java language till date and would be grateful if someone could enlighten me in this particular area.
I can probably prove or disprove this by memory profiling but I want a theoretical solution to this issue with a reference link if possible.
[ December 09, 2002: Message edited by: Suneet Kamath ]
[ December 09, 2002: Message edited by: Suneet Kamath ]
 
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Suneet
I agree with you on this


but the "data segment" is different for each.


By breaking up a single class into multiple class does not mean that you are going to have reduced memory. You still will have the same amount of data stored in one or in multiple classes.
 
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, about breaking it up into smaller classes and accessing them..
well that depends on how you design the class.
On the facet it looks as if, when this big class was done, a lot of brainstorming was done to decide on its responsibilities.
But then now that you want to re-define the CRC ( read as classes, responsibility and collaboration ) it is wise to have all the common data put in one data class/object and have it as a singleton, static.
That would save you the data segment cost, since you shant have to have a redundancy in the data.
But as far as the code segment goes, you need to dig deeper into JVM and find out how the execution of the lines of code is going to be, and what would be the best way to implement it.
Ofcourse, the profiler would be a good idea to start with on the collaboration design.
Lupo
 
reply
    Bookmark Topic Watch Topic
  • New Topic