Terracotta DSO

JVM Coordination Sample Application

About

The relevant implementation detail from this sample application is that it shows how to coordinate threads in a multi-VM environment using the same patterns one would use in a single-VM multi-threaded environment.

To accomplish this, the application instruments a CyclicBarrier implementation and uses it to coordinate the threads between VMs.

The CyclicBarrier library used is from Doug Lea (http://g.oswego.edu/) but you should be able to easily switch it to Sun's own CyclicBarrier implementation for the JDK 1.5

Build Instructions

This sample application ships built ready to run.  If you modify the application code, use the provided build.xml file to re-build the application with Apache Ant (ant build).

Run Instructions

The command-line steps below for executing scripts on Windows can be replaced by double-clicking the script instead.
  1. Start a Terracotta server from the samples directory.

    Unix: ./start-demo-server.sh
    Windows: start-demo-server.bat
  2. Start multiple copies of the application from the samples/pojo/coordination directory.

    Unix: ./run.sh &
    ./run.sh &

    Windows: run.bat
    run.bat


    Optionally, the number of VMs that will participate may be supplied to the run scripts; otherwise it assumes a maximum of 2 VMs will be present.

  3. View application.
    The application will block until the maximum number of VMs have been instantiated, after which, they will all perform their task - in this case getting and printing the system time's current value.

Source Code

Browse configuration file and source code: source.html