Volatile Variable in java

Volatile variable is more useful in java. Now a days we using multithread in many

Java projects. During this we can use the volatile keyword.

Best scenario for using volatile variable:

In multiple thread concept may be single instance can be used by multiple thread .That time the volatile variable will be use for programmer...Because without volatile variable means if one thread will be changed by user it will affect by other threads also.

During this time we can mention master copy variable we mention as volatile variable..because of this other than master variable will be update value  it actually update in cache memory not in main memory variable memory

Declaring a volatile variable

Class exvolatile

{

volatile int val;

.....

}


Like it on Facebook, Tweet it or share this article on other bookmarking websites.

Comments (0)

There are no comments posted here yet

Should human rights awareness be increased in India?

No answer selected. Please try again.
Please select either existing option or enter your own, however not both.
Please select minimum 0 answer(s) and maximum 2 answer(s).
/polls/day-to-day-issues/6616-human-rights.json?task=poll.vote
6616
checkbox
[{"id":"23014","title":"Yes","votes":"43","type":"x","order":"1","pct":89.58,"resources":[]},{"id":"23015","title":"No","votes":"5","type":"x","order":"2","pct":10.42,"resources":[]}] ["#ff5b00","#4ac0f2","#b80028","#eef66c","#60bb22","#b96a9a","#62c2cc"] ["rgba(255,91,0,0.7)","rgba(74,192,242,0.7)","rgba(184,0,40,0.7)","rgba(238,246,108,0.7)","rgba(96,187,34,0.7)","rgba(185,106,154,0.7)","rgba(98,194,204,0.7)"] 350
bottom 200
No married couple wants to end up getting divorced. It is not like they have planned for it. They try to put up with their partners for as long as they
Due to our modern lifestyle, we feel that digestion related disorders are a common problem. Thus, we neither give importance to them nor seek any help
The bond of marriage brings the two people together. Initially, everything may seem okay and both of them slowly start discovering each other in the journey.
Why to choose Java? In the computer market, being able to use Java is a crucial knowledge. Java is a development terminology used to build compelling
DATABASE CONNECTIVITY This articles explains the need of database connectivity, the way it is achieved through Java using the JDBC(java database connectivity)
  Write your first simple java program.   First of all we need is a placewhere we can write your Java code. All Java programs are written using
Array of objects in Java Arrays are defined as block of continous memory locations which are arranged in one after another. Elements of the Array can
Synchronized block is alternative mechanism for "synchronized" methods.If we inherihate the non synchronized blocks either from base class or interface