P
pvbemmel-at-xs4all-nl
I find it hard to match my intuition of program order, as being
the order given by lines in the source code,
to definition of "program order" in the Java Language Specification.
The definition given by wikipedia, seems much clearer.
Both are reproduced below.
Why is the JLS definition so hard to understand?
Can anybody explain?
Paul van Bemmelen.
The Java Language Specification, Third Edition, section 17.4.3 "Programs
and Program Order" , states:
----------------------------------------------
Among all the inter-thread actions performed by each thread t, the
program order of t is a total order that reflects the order in which
these actions would be performed according to the intra-thread semantics
of t.
----------------------------------------------
The introduction to section 17.4 "Memory Model" , states about
"intra-thread semantics" :
----------------------------------------------
The memory model determines what values can be read at every point in
the program. The actions of each thread in isolation must behave as
governed by the semantics of that thread, with the exception that the
values seen by each read are determined by the memory model. When we
refer to this, we say that the program obeys intra-thread semantics.
Intra-thread semantics are the semantics for single threaded programs,
and allow the complete prediction of the behavior of a thread based on
the values seen by read actions within the thread.
----------------------------------------------
In www.wikipedia.org , the entry for "java memory model" states
-----------------------------------------------
For execution of a single thread, the rules are simple. The Java
Language Specification requires a Java Virtual Machine to observe
within-thread as-if-serial semantics. The runtime (which, in this case,
usually refers to the dynamic compiler, the processor and the memory
subsystem) is free to introduce any useful execution optimizations as
long as the result of the thread in isolation is guaranteed to be
exactly the same it would have been had all the statements been executed
in the order the statements occurred in the program (also called program
order).
-----------------------------------------------
the order given by lines in the source code,
to definition of "program order" in the Java Language Specification.
The definition given by wikipedia, seems much clearer.
Both are reproduced below.
Why is the JLS definition so hard to understand?
Can anybody explain?
Paul van Bemmelen.
The Java Language Specification, Third Edition, section 17.4.3 "Programs
and Program Order" , states:
----------------------------------------------
Among all the inter-thread actions performed by each thread t, the
program order of t is a total order that reflects the order in which
these actions would be performed according to the intra-thread semantics
of t.
----------------------------------------------
The introduction to section 17.4 "Memory Model" , states about
"intra-thread semantics" :
----------------------------------------------
The memory model determines what values can be read at every point in
the program. The actions of each thread in isolation must behave as
governed by the semantics of that thread, with the exception that the
values seen by each read are determined by the memory model. When we
refer to this, we say that the program obeys intra-thread semantics.
Intra-thread semantics are the semantics for single threaded programs,
and allow the complete prediction of the behavior of a thread based on
the values seen by read actions within the thread.
----------------------------------------------
In www.wikipedia.org , the entry for "java memory model" states
-----------------------------------------------
For execution of a single thread, the rules are simple. The Java
Language Specification requires a Java Virtual Machine to observe
within-thread as-if-serial semantics. The runtime (which, in this case,
usually refers to the dynamic compiler, the processor and the memory
subsystem) is free to introduce any useful execution optimizations as
long as the result of the thread in isolation is guaranteed to be
exactly the same it would have been had all the statements been executed
in the order the statements occurred in the program (also called program
order).
-----------------------------------------------