InterviewSolution
| 1. |
What Is A Volatile Keyword? |
|
Answer» In GENERAL each THREAD has its own copy of VARIABLE, such that one thread is not concerned with the VALUE of same variable in the other thread. But sometime this may not be the case. Consider a scenario in which the count variable is holding the number of times a METHOD is called for a given class irrespective of any thread calling, in this case irrespective of thread access the count has to be increased so the count variable is declared as volatile. In general each thread has its own copy of variable, such that one thread is not concerned with the value of same variable in the other thread. But sometime this may not be the case. Consider a scenario in which the count variable is holding the number of times a method is called for a given class irrespective of any thread calling, in this case irrespective of thread access the count has to be increased so the count variable is declared as volatile. |
|