com.ibm.tspaces.examples.mergesort
Class MergeSort2

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--com.ibm.tspaces.examples.mergesort.MergeSort2

public class MergeSort2
extends java.lang.Thread

This class implements a merge sort using TupleSpace. It is an example of how to use the com.ibm.tspaces package. It generates a number of random integers and then uses TupleSpace as a communication medium to coordinate the activities of a number of threads that perform the actual sorting/merging. This version of MergeSort2 makes use of the Merger class that implements the Eval interface so that Worker threads on other systems can do the work.

Author:
Daniel Ford
See Also:
Tuple, Field, TupleSpace

Field Summary
static java.lang.String DEFAULTSERVERNAME
          The default name of the server hosting the tuple space for the sort.
static java.lang.String DEFAULTSPACENAME
          The default name of the tuple space to use to do the sorting in.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MergeSort2(int numberOfInts, java.lang.String serverName, java.lang.String spaceName, int tasks)
          Sort a set of randomly generated integers.
 
Method Summary
static void main(java.lang.String[] argv)
          The starting point of execution for the merge sort.
 void run()
          Starting point of execution for thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULTSPACENAME

public static final java.lang.String DEFAULTSPACENAME
The default name of the tuple space to use to do the sorting in.

DEFAULTSERVERNAME

public static final java.lang.String DEFAULTSERVERNAME
The default name of the server hosting the tuple space for the sort.
Constructor Detail

MergeSort2

public MergeSort2(int numberOfInts,
                  java.lang.String serverName,
                  java.lang.String spaceName,
                  int tasks)
Sort a set of randomly generated integers.
Parameters:
numberOfInts - the number of random integers to generate and then sort.
maxIntValue - the maximum value of one of the randomly generated integers to be sorted.
tasks - the number of threads to be used to sort the the integers. Each one will make its own accesses to the TupleSpace.
spaceName - the name of the space to be used to do the sorting.
serverName - the name of the server that is managing the space.
Method Detail

run

public void run()
Starting point of execution for thread.
Overrides:
run in class java.lang.Thread

main

public static void main(java.lang.String[] argv)
The starting point of execution for the merge sort.