The Well-Grounded Java Developer


The state model for a thread

The Java Memory Model (JMM)

The JMM is described in section 17.4 of the Java Language Specification (JLS). This is quite a formal part of the spec, and it describes the JMM in terms of synchronization actions and the mathematical construct known as a partial order. This is great from the point of view of language theorists and implementers of the Java spec (compiler and VM makers), but it’s worse for application developers who need to understand the details of how their multithreaded code will execute.

Rather than repeat the formal details, we’ll list the most important rules here in terms of a couple of basic concepts: the Synchronizes-With and Happens-Before relationships between blocks of code.

  • Happens-Before — This relationship indicates that one block of code fully completes before the other can start.
  • Synchronizes-With — This means that an action will synchronize its view of an object with main memory before continuing.

. . .



Run from jar with dependencies


For run main class from jar with dependencies:

java -cp example.jar:lib/*:. mypackage.MyClass - UNIX
java -cp example.jar;lib/*;. mypackage.MyClass - Windows

My example:

java -cp HelloWorld.jar:Dependency1.jar:Dependency2.jar net.kozinaki.common.HelloWorld