What is the definition and use of volatile and transient in java

Showing Answers 1 - 3 of 3 Answers

Smitha

  • Nov 27th, 2006
 

Volatile variables are those which do not retain the values supplied in memory.

Transient variables do not participate during object serialization .The variable which are marked as transient will not be sent as a part of the object during the serialization process.

volatile is 4 da threadings. in threadings u are having two types of memory. Main memory and threadings local memory. threadings local memory is like a screen shot of main memory. Like screenshot it is not current, but looks like memory when screenshot is taken.volatile tells teh thred not use screenshot of variable, but use main memory instead. this is so it is always uptoday.

Bhumika

  • Dec 7th, 2006
 

In addition to this the reverse of transient is

"serialPersistentFields "These fields should be stored by serialization."

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions