• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is volatile keyword in Java?
#1
What is volatile keyword in Java?
Reply
#2
Declaring a volatile Java variable means: The value of this variable will never be cached thread-locally: all reads and writes will go straight to "main memory"; Access to the variable acts as though it is enclosed in a synchronized block, synchronized on itself.
Reply
#3
Holle Everyone..!
It's probably fair to say that on the whole, the volatile keyword in Java is poorly documented, poorly understood, and rarely used. To make matters worse, its formal definition actually changed as of Java 5. On this and the following pages, we will cut through this mess and look at what the Java volatile keyword does and when it is used.
Thanks.....
Reply
#4
Volatile keyword in Java is used as an indicator to Java compiler and Thread that do not cache value of this variable and always read it from main memory .
Reply
#5
Volatile keyword is a qualifier that is applied to a variable when it is declared. It tells the compiler that the value of the variable may change at any time--without any action being taken by the code the compiler finds nearby. A variable should be declared volatile whenever its value could change unexpectedly.
Cheap VPS | $1 VPS Hosting
Cheap Windows VPS | Windows with Remote Desktop Access
Cheap Dedicated Server | $29 Dedicated Server with Free IPMI
Reply
#6
I'm also wondering about this issue! Expert in solving help me!
Thanks!
Mr. Quan Ha
403  FukiStore - Smartphone Accessories Shop!!!
Heart  Thanks & Best Regard!
Reply
#7
volatile keyword in Java guarantees that value of the volatile variable will always be read from main memory and not from Thread's local cache. 3. In Java reads and writes are atomic for all variables declared using Java volatile keyword (including long and double variables).
Reply
#8
What is the Java volatile keyword? ... Declaring a volatile Java variable means: The value of this variable will never be cached thread-locally: all reads and writes will go straight to "main memory"; Access to the variable acts as though it is enclosed in a synchronized block, synchronized on itself.
Reply
#9
great
Reply
#10
thanks for the help
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Java or php? sumitmodi 17 1,471 11-12-2018, 04:47 AM
Last Post: alexcollins
  encapsulation in java..? mahisharma3200 8 287 11-11-2018, 11:44 AM
Last Post: haanhquan89
  Differentiate between StringBuffer and StringBuilder in Java programming. sulbha 1 146 09-11-2018, 11:11 PM
Last Post: sankalppatil
  What is difference between CyclicBarriar and Countdown Latch in Java ? sulbha 1 326 03-05-2018, 02:49 AM
Last Post: WebExpert
  Net or Java on Linux? confused after .Net is Open Source richardwalter 2 406 02-14-2017, 02:41 AM
Last Post: John Cage
  How to write data from MySql table to Excel using Java - See more at: https://www.gid richardwalter 0 350 02-11-2017, 04:47 AM
Last Post: richardwalter
  Java Help please.. richardwalter 0 305 02-04-2017, 06:03 AM
Last Post: richardwalter
  What Differs JavaScript from Java ? beingchinmay 0 780 01-07-2016, 01:28 AM
Last Post: beingchinmay
  JavaScript Resembles Java beingchinmay 0 597 01-07-2016, 12:56 AM
Last Post: beingchinmay

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


Webmasterbabble.com, © 2012-2018 .