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

Hello, I am new in iOS development. What is the best way of learning iOS and Programming also?
You could start learning objective C for iOS app development. Please contact us for more information.
Vikas
Hello Sir, I want to start my IT career. I had done MBA Finance and marketing. Please tell me sir which IT course is best In SAP.
Hi Rajashekar, You can go with SAP FICO. FINANCING AND CONTROLLING. if ur interested In financing. If willing to do then call to me
Rajasekhar
How do I learn Java? From book or internet or a coaching?
According to me....u should start from basic Java..that is core Java... . Find coaching , who teaches Java for beginners.....then later u can go for advance java.
Suresh
0 0
7

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

Ask a Question

Related Lessons

Learning a BI Tool
Before learning a BI Tool, make sure that you have good understanding of Oralce(SQL Language) Database and ETL Concepts. So that you will be able to grasp/Learn it fast and easy. Top 10 BI Tools : Informatica...


Microsoft Outlook
Microsoft Outlook is the preferred email client used to access Microsoft Exchange Server email. Not only does Microsoft Outlook provide access to Exchange Server email, but it also includes contact, calendaring...

My first C++ program
# include using namespace std; int main() { cout<<"Welcome to C++"; return 0; } Use IDE such as CodeBlocks to run this program. To do this, open CodeBlocks, Goto File->New->Empty File. Copy...

Why is the Hadoop essential?
Capacity to store and process large measures of any information, rapidly. With information volumes and assortments always expanding, particularly from web-based life and the Internet of Things (IoT), that...

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