• 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

Some Basic Doubts

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am confused with some questions, please answer in a simple way so that i can understand...
1) why are wait(), notify() and notifyAll() in the Object class although we use it only while threading?
2) why can't static and transient variables be serialized?
3) what is the difference between a argument and parameter?

Thanks and Regards,
Subhadeep
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by subhadeep chakraborty:
1) why are wait(), notify() and notifyAll() in the Object class although we use it only while threading?


So you can synchronize on any object you wish to, since all objects will inherit those methods. If it were methods of Thread then you could only synchronize on the thread.

2) why can't static and transient variables be serialized?


The transient keyword is invented just to prevent the variable from being serialized. Sometimes a variable isn't serializable, but you can reconstruct it from other information (such as an InputStream). Without the transient keyword the entire object would be non-serializable.

As for static - it's an instance of a class that is serialized. Static variables are not related to the instance but the entire class. If you would deserialize it, there is still the existing information in the static variable.

3) what is the difference between a argument and parameter?


I think it's just a matter of name calling. I mix them up myself sometimes.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic