<p>Shared object vs owncopies.</p>
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   aniruddha_ghorpade
Posted On:   Monday, October 21, 2002 09:39 AM

I have a class say EngineConfig in which I have all the members and member functions as static. Now I am accessing the object of The EngineConfig say. EngineConfig e = new EngineConfig(). The non static way through a class say NCAEngine.Now I have different instances of the of NCAEngine. So Does Each instance of NCAEngine have its own copy of the object e or does it have shared copies of the EngineConfig. I am asking this Question because even if i make the member functions and members all static or all non static I am not seeing any difference. Also I feel If I had accessed the members or member functons of EngineConfig the static way , I mean just calling EngineConfig object instead of creating Engine   More>>


I have a class say EngineConfig in which I have all the members and member functions as static.
Now I am accessing the object of The EngineConfig say.
EngineConfig e = new EngineConfig(). The non static way through a class say NCAEngine.Now I have different instances of the of NCAEngine.

So Does Each instance of NCAEngine have its own copy of the object e or
does it have shared copies of the EngineConfig.

I am asking this Question because even if i make the member functions and members all static or all non static I am not seeing any difference.
Also I feel If I had accessed the members or member functons of EngineConfig the static way , I mean just calling EngineConfig object instead of creating EngineConfig e = new EngineConfig(), this would have made the difference.
Please let me know what I am doing.whether each instance of the NCAEngine is having its own copy of the object e or is it shared copy???

   <<Less

Re: <p>Shared object vs owncopies.</p>

Posted By:   aniruddha_ghorpade  
Posted On:   Tuesday, October 22, 2002 08:09 AM


To make the above Question more clear . I shall put it this way.
1] From the Class NCAEngine to be more specific in the run() method of NCAEngine . I want each thread inside NCAEngine to have its own copy of EngineConfig so I create an object of EngineConfig in the run method by saying EngineConfig e = new EngineConfig();




Now I know for sure that if I have all members and member functions of EngineConfig as Non Static. Than each NCAEngine
will have an individual own copy of the object e.






But My concern My Question is,


Q1]If I have all the memberfunctions and members as Static than will each NCAEngine have an individual own copy of the object e.???


IF yes . than Q2] and Q3]


Q2] what is the difference in the object created by using all memberss and member funcions as non static and the all member functions as static.
which is beter way of doing I mean from performance and memory issues.






Q3] Will this object created by using members and member functions static behave the same way under all circumstances as object created by using members and member functions as non static especially from the point of multithreading?





IF you can provide answers pointwise,I mean as per my Question.I shall highly Appreciate that.
Thanks
Aniruddha.



About | Sitemap | Contact