Explain Java Memory Model?

Questions by divya_a

Showing Answers 1 - 3 of 3 Answers

YON

  • Feb 15th, 2006
 

The Java Memory Model defines how threads interact through memory.

  Was this answer useful?  Yes

YON

  • Feb 15th, 2006
 

Well what i feel about JMM isThe JavaMemoryModel allows the compiler and cache to take significant liberties with the order in which data is moved between a processor-specific cache/ register and main memory, unless the programmer has explicitly asked for certain visibility guarantees using synchronized or volatile. This means that in the absence of synchronization, memory operations can appear to happen in different orders from the perspective of different threads.A class defined without any synchronization:final class check1{ private int a = 0; private long b = 0; void set() { a = 1; b = -1; } boolean check() { return ((b == 0) || (b == -1 && a == 1)); }}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions