JCoBox is a programming language, which extends Java by a new concurrency concept, called CoBoxes. CoBoxes are a novel programming concept for distributed, concurrent object-oriented software, developed in our group. CoBoxes are a generalization of active objects to concurrently running groups of objects with multiple cooperative tasks. The CoBox concept has been integrated into Java in the JCoBox language. More information about CoBoxes and !JCoBox can be found in our latest paper: JCoBox: From Active Objects to Concurrent Components. Or you can start with the tutorial.

Language Features

JCoBox is a generalization of sequential Java. That is, every sequential Java program is a legal JCoBox program. Concurrency in JCoBox is handled by the following languages features:

CoBox Classes

CoBox classes are annotated by @CoBox. Instantiating cobox classes does two things: a new cobox is created and a new object of the corresponding class is created, hosted by the new cobox. The result is a reference to the new object.

Asynchronous Method Calls

Asynchronous method calls are denoted by an exclamation mark (!) instead of a dot (.). They immediately return to the caller with a future as result. Asynchronous method calls create new tasks (cooperatively scheduled threads) in the cobox of the receiver object.


Futures are place-holders for results of asynchronous method calls. They allow for a data-flow-like synchronization of tasks. Futures can also be created explicitly for flexible synchronization between tasks.

Cooperative Task Scheduling

Within a cobox, tasks are scheduled cooperatively. This means that the active task has exclusive access to the state of the whole cobox until it either terminates or explicitly releases the cobox. Note the state of a cobox can consist of multiple objects.


Ping Pong Example

@CoBox  // the @CoBox annotation declares a cobox class
class Ping {
   Pong pong;
   boolean stopped;
   Ping(Pong p) {
      pong = p;
      // asynchronous self-call to
      // realize an active object

   void start() {
      stopped = false;
      while (! stopped) {
         // asynchronous method call, which immediatly
         // returns with a future to the result of the call
         Fut<String> fut = pong!ping("Hello");

         // waiting non-blockingly for the future,
         // thus releasing the cobox,
         // and allowing stop calls to be executed
         String answer = fut.await();

   void stop() {
      stopped = true;
class Pong {
   String ping(String s) {
      return s+" World";

class Main {
   public static void main(String... args) {
      // at this point we are in the MAIN cobox
      Pong pong = new Pong();
      Ping ping = new Ping(pong);

      // wait and block the ROOT cobox for 5 seconds
      JCoBox.sleep(5, TimeUnit.SECONDS);

      // synchronous calls are syntactic sugar
      // and semantically equivalent to
      // asynchronous calls with an immediate
      // blocking future read: ping!stop().get();

Precompiled Examples

  • jcobox-examples.jar - Self-contained JAR file consisting of several examples implemented in JCoBox.
    • Four Wins: java -cp jcobox-examples.jar fourwins.FourWins
    • Analog Clock: java -cp jcobox-examples.jar jcobox.examples.swing.clock.Clock
    • Thermostat: java -cp jcobox-examples.jar jcobox.examples.swing.thermostat.Thermostat
    • Dining Philosophers: java -cp jcobox-examples.jar jcobox.examples.classic.dining.Philosophers
    • Santa Claus: java -cp jcobox-examples.jar jcobox.examples.classic.santaclaus.SantaClaus
    • Ping Pong: java -cp jcobox-examples.jar jcobox.examples.classic.pingpong.PingPong

Examples via Java Web Start


A compiler for JCoBox has been implemented in our group, which can be used to write concurrent Java programs using CoBoxes and futures instead of using threads and locks.


This is a research prototype and hence is experimental software. It should only be used for testing purposes and not in any productive environment.

Precompiled JAR files

The following JAR files all contain only compiled class files. The corresponding source files can be downloaded from the Git-Repository below.

  • jcobox.jar - JCoBox compiler. Needed to compile jcobox files.
    • Execute with java -jar jcobox.jar <jcobox files>
  • jcobox-runtime.jar - JCoBox runtime library. Contains only the classes needed for running JCoBox programs.
    • Run JCoBox programs with java -cp jcobox-runtime.jar:$CLASSPATH my.jcobox.Program




API Documentation

The API documentation is included in the snapshots, but can also be viewed online.

Maude Formalization

The semantics of JCoBox is precisely defined by a Maude formalization.


For further information please feel free to contact Jan Schäfer.