Java applet flow diagram

[Here's some general information on how a typical Java applet is structured. If you already know this stuff, you can skip straight to the description of CyberCardiologist. Also of possible interest: a flow diagram of our 2-D LRd code written in C++.]

The Java programming language is a thread-based object-oriented language. You can think of threads as mini-programs which are, in general, executed in parallel with one another. A single Java application, known as an applet, is usually composed of several threads. The threads are interpreted and executed by an overseeing entity known as the Java virtual machine. There are typically times when the execution of one thread depends on variables which another thread is in the middle of using. For this situation, Java has provisions which allow one thread to wait while another is executing.

As an object-oriented language, Java allows one class to inherit from another. As is the case in C++, methods in the parent class can be overriden in the subclass, and new methods may be added. Unlike C++, multiple inheritance is not allowed. Instead Java, allows the definition of so-called "interfaces" which classes can "inherit" from simply by defining the methods declared in the interface. The inheritance from an interface class is called "implementation" of the interface class in Java terminology. A class is allowed to implement as many interface classes as it wants to.

When a Java applet is part of a Web page requested by the user, the browser starts up its Java virtual machine, which then starts an object which has been subclassed from the Applet class. A supervisor thread is also started, as shown in the diagram below. In the diagram, CyberCardiologist is the class name of the subclassed Applet. The Applet methods init(), start(), and stop() have all been overridden by CyberCardiologist. By "starting" CyberCardiologist, I mean that init() is first called, followed by start().

In CyberCardiologist, the start() routine has been redefined to create and start a Thread object. The Thread object, in turn, has been defined with Main_program as its target. The target of a Thread must always be an object which implements the Runnable interface. As illustrated in the diagram, Main_program is such an object. The start() routine in a Thread object is always defined to call the run() routine in its target. It is this run() routine which contains most of the "guts" of the Java applet.

How CyberCardiologist is implemented.