What is volatile variable in java. When it can be useful.

Asked by Last Modified  

4 Answers

Follow 0
Answer

Please enter your answer

Trainer

volatile is used to indicate that a variable's value will be modified by different threads. Value will not be stores in thread cache. All the operations will work with the main copy. Its acts as it is in a synchronized block.
Comments

Tutor

volatile variable in Java is a special variable which is used to signal threads, compiler that this particular variables values is going to be updated by multiple thread inside Java application. By making a variable volatile using volatile keyword in Java, application programmer ensures that its value...
read more
volatile variable in Java is a special variable which is used to signal threads, compiler that this particular variables values is going to be updated by multiple thread inside Java application. By making a variable volatile using volatile keyword in Java, application programmer ensures that its value should always been read from main memory and thread should not used cached value of that variable from there own stack. When to use Volatile variable in Java This is the most important thing to learn while learning about volatile variable in Java. When to use volatile variable in Java is also a famous multi-threading interview question in Java. here are some of the scenario where you can use volatile variable in Java : 1) Any variable which is shared between multiple threads should be made variable, in order to ensure that all thread must see latest value of volatile variable. 2) A signal to compiler and JIT to ensure that compiler does not change ordering or volatile variable and moves them out of synchronized context. 3) You want to save cost of synchronization as volatile variables are less expensive than synchronization. read less
Comments

Tutor

http://java67.blogspot.in/2012/08/what-is-volatile-variable-in-java-when.html
Comments

Tutor

http://java.dzone.com/articles/java-volatile-keyword-0
Comments

View 2 more Answers

Related Questions

How much beneficial it would be for me to get a job as certified business analyst if I pursue a course in BIG DATA AND R as I am a commerce graduate and having experience in banking.
It certainly give you benefit. But path is long & not so easy. It dons't mean too long or tough. Take around 6 months of exhaustive learning. You also need to learn some related applications/system for execution.
Indranil
Who can learn the Python?
Anyone can learn python doesn't require any programming knowledge (or) experience. Python is much easier as compared to other programming languages. Python is easy to learn. The learning curve is very gradual.
Sunil
What is cloud computing. Is it ok MBA qualification for cloud computing?
Cloud computing is a internet based computing model in which computing resources are used on demand and pay per use model over the internet. Private, public and hybrid are three different types of cloud...
Praveen
I need your help to choose my career as I have three years of gap between my education. I know SQL. Can anyone tell me should I choose MS SQL server or oracle because I am interested in the database? Which one will be better to learn to get into the IT industry? Please help me! Thank you!
As you are strong and interested in SQL, why not to choose ETL Testing? It has a good career ahead in data projects. To survive in the market, you need both Oracle & SQL Server. Actually, both are almost same but are different products.
Santhosh

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Basic Concepts of Web Designing
An introduction to domain names, web servers, and website hosting 1)What is the web? In a nutshell, the web is a whole bunch of interconnected computers talking to one another. The computers (on the...

How to add a diagonal line in a cell in MS EXCEL
Many a times we feel the need to use a cell to act as headers for data flowing in two directions -- Rows and columns and for this purpose we may want to add a diagonal line to accomodate the two headers...

How To Minimize The Page Splits In Sqlserver To Improve The Performane Of Database?
How to minimize the page splits in sqlserver to improve the performane of database? Page Splits: A page is 8Kbytes of data which can be index related, data related, large object binary (lob’s)...

Basics Of R Programming 1
# To know the working directory which is assigned by defaultgetwd()# set the working directory from where you would like to take the files setwd("C:/Mywork/MyLearning/MyStuddocs_UrbanPro/Data") # Assign...

Understanding Big Data
Introduction to Big Data This blog is about Big Data, its meaning, and applications prevalent currently in the industry.It’s an accepted fact that Big Data has taken the world by storm and has become...
M

Mymirror

0 0
0

Recommended Articles

Applications engineering is a hot trend in the current IT market.  An applications engineer is responsible for designing and application of technology products relating to various aspects of computing. To accomplish this, he/she has to work collaboratively with the company’s manufacturing, marketing, sales, and customer...

Read full article >

Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...

Read full article >

Hadoop is a framework which has been developed for organizing and analysing big chunks of data for a business. Suppose you have a file larger than your system’s storage capacity and you can’t store it. Hadoop helps in storing bigger files than what could be stored on one particular server. You can therefore store very,...

Read full article >

Business Process outsourcing (BPO) services can be considered as a kind of outsourcing which involves subletting of specific functions associated with any business to a third party service provider. BPO is usually administered as a cost-saving procedure for functions which an organization needs but does not rely upon to...

Read full article >

Looking for IT Courses ?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you