Comment on Tutorial - Transient vs Volatile modifiers in Java By Reema sen



Comment Added by : Javin @ eclipse remote debugging

Comment Added at : 2011-03-11 22:00:15

Comment on Tutorial : Transient vs Volatile modifiers in Java By Reema sen
Nice artielce , by the way just to add from my experience I think we should make a variable volatile when we want ensure that thread doesn' cache the value of variable ,e.g. in below code
while(!stop) {
doWork() ;
}

Thread can cache the value of "stop" instead of getting it from main memory every time and if in between any other thread changes the value , it would not be visible to this thread. making boolean variable "stop" as volatile ensures this will not happen.

Thanks
Javin
<a href="http://javarevisited.blogspot.com/2010/10/what-is-deadlock-in-java-how-to-fix-it.html">How to avoid deadlock in Java code </a>


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. When the Value Is Returned To The Method Then How
View Tutorial          By: nitin deep singh at 2011-08-09 11:43:07

2. I tried the first option i.e for refresh use Forwa
View Tutorial          By: dinesh at 2009-07-31 05:31:23

3. Very good explanation specially overlapped memory
View Tutorial          By: MANISH RASTOGI at 2010-06-22 05:44:07

4. great work
View Tutorial          By: Bhaskaran at 2013-01-21 11:23:19

5. that is fifo rigth? how about lifo?
View Tutorial          By: galz at 2015-02-18 03:03:31

6. This program is mush faster and finer than given p
View Tutorial          By: Anonymous at 2013-02-27 05:38:27

7. nice material
View Tutorial          By: ravi at 2008-12-24 00:40:12

8. Simplified explanation with perfect Examples
View Tutorial          By: Sushant Chaudhary at 2010-07-12 00:32:18

9. ..i have a question. is it possible to override a
View Tutorial          By: rein at 2010-08-25 07:07:15

10. Hello Friends, i am getting an error in following
View Tutorial          By: Albin at 2008-07-10 23:49:33