Javatpoint Logo

What is volatile keyword and is-a relation in Inheritance

By: nisars*** On: Sun Nov 24 09:03:47 EST 2013     Question Reputation8 Answer Reputation0 Quiz Belt Series Points0  8Blank User
what is the use of volatile keyword in java
and tell me regarding is-A and use-A relation in Inheritance
Up0Down

 
volatile is used to indicate that a variable's value will be modified by different threads.

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.

Inheritance shows IS-A relation.
eg:
class Animal
{}
class Dog extends Animal
{}

here, Dog IS-A Animal i.e., subclass is a type of super class.
Image Created5Down

By: [email protected] On: Mon Nov 25 00:53:52 EST 2013 Question Reputation0 Answer Reputation359 Belt Series Points0 359User Image
Are You Satisfied :4Yes1No
 


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

Java volatile keyword cannot be used with method or class and it can only be used with variable.This keyword also guarantees visibility and ordering , after Java 5 write to any volatile variable happens before any read into volatile variable. volatile keyword also prevents compiler or JVM from reordering of code or moving away them from synchronization barrier.

to have good knowledge of this read the Multithreading topic of javatpoint.
Image Created0Down

By: [email protected] On: Mon Nov 25 04:50:36 EST 2013 Question Reputation0 Answer Reputation392 Belt Series Points0 392User Image
Are You Satisfied :1Yes1No
 
Image Created0Down

By: [email protected] On: Mon Nov 21 13:22:20 IST 2016 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No