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. to get more and clear information about java progr
View Tutorial          By: SWARNA at 2010-09-13 04:23:10

2. good but not best
View Tutorial          By: VIVEK at 2010-03-09 03:00:21

3. thanks for providing such services...
View Tutorial          By: vara at 2008-11-18 02:07:17

4. thanks for giving suitable example to understand m
View Tutorial          By: akash dange at 2011-12-21 05:40:36

5. I 've tried the program for Bubble Sort. This prog
View Tutorial          By: Siva at 2012-04-17 05:19:28

6. how to downlow the different 5 files please !!
View Tutorial          By: Agnin at 2009-06-24 05:29:09

7. Plz. help me in getting code to read messages usin
View Tutorial          By: Jaydatta at 2009-04-03 20:58:57

8. thanx for this post...its my exam of java day afte
View Tutorial          By: Prakhar at 2012-01-08 00:16:24

9. Plz send code of sending sms from java code...

View Tutorial          By: Shekh at 2014-11-27 14:18:25

10. Hi, this was useful. how can integrate j2me progra
View Tutorial          By: karthik at 2013-01-23 10:02:02