Welcome to Questionaries, where you can ask questions and receive answers from other members of the community.

Let us know at info@questionaries.org

What was wrong with the old memory model?

5 like 0 dislike
Hello guys,

Anybody know What was wrong with the old memory model?

Please give me your feedback.
asked 1 year ago by daneim (127,080 points)

1 Answer

1 like 0 dislike
 
Best answer
There were several serious problems with the old memory model. It was difficult to understand, and therefore widely violated. For example, the old model did not, in many cases, allow the kinds of reorderings that took place in every JVM. This confusion about the implications of the old model was what compelled the formation of JSR-133.

One widely held belief, for example, was that if final fields were used, then synchronization between threads was unnecessary to guarantee another thread would see the value of the field. While this is a reasonable assumption and a sensible behavior, and indeed how we would want things to work, under the old memory model, it was simply not true. Nothing in the old memory model treated final fields differently from any other field -- meaning synchronization was the only way to ensure that all threads see the value of a final field that was written by the constructor. As a result, it was possible for a thread to see the default value of the field, and then at some later time see its constructed value. This means, for example, that immutable objects like String can appear to change their value -- a disturbing prospect indeed.

This information collect a website. I think this is a proper soluation
answered 1 year ago by marck_don (191,010 points)

Related questions

4 like 0 dislike
1 answer
asked 1 year ago by daneim (127,080 points)
4 like 0 dislike
1 answer
7 like 0 dislike
0 answers
asked 1 year ago by eagles11 (179,830 points)
10 like 0 dislike
1 answer
11 like 0 dislike
0 answers
asked 2 years ago by biswaskeran (70,430 points)