Not every HPJava program is a parallel program. In Chapter 1 we saw some examples of sequential HPJava codes. In fact any standard Java class can be used by an HPJava program, and typically the methods of standard Java classes aren't parallel programs.
For various reasons, some of which should become apparent as we go along, the HPJava system needs an unambiguous way to tell whether a given piece of code is supposed to be executed in a parallel way--distributed across multiple processes. In HPJava this is flagged by implementing a marker interface. Marker interfaces are a familiar mechanism in Java. Well known examples are the java.io.Serializable interface, which marks the instances of a particular class as being serializable, and the java.rmi.Remote interface, which marks the methods of a class as being remotely callable.
HPJava defines a marker interface hpjava.lang.HPspmd. Any class that implements this interface is referred to as an HPspmd class. The methods and constructors of HPspmd classes are supposed to be executed in a parallel context--they are meant to be invoked concurrently by a group of cooperating processes.
Consider these two examples:
Suppose we save these fragments in source files EgSeqHello.hpj and EgParHello.hpj respectively, and compile them using the hpjavac command as described in section 1.1.2. We assume that the class path is set up as described there, so that we are running under the multithreaded model.
If we start either class without specifying the hpjava.numprocs
property, the result is the same