com.ibm.tspaces.examples.mergesort
Class MergeSort

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

public class MergeSort
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.

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
MergeSort()
          Sort a set of randomly generated integers.
MergeSort(int numberOfInts)
          Sort a set of randomly generated integers.
MergeSort(int numberOfInts, java.lang.String serverName)
          Sort a set of randomly generated integers.
MergeSort(int numberOfInts, java.lang.String serverName, int maxIntValue)
          Sort a set of randomly generated integers.
MergeSort(int numberOfInts, java.lang.String serverName, int maxIntValue, java.lang.String spaceName)
          Sort a set of randomly generated integers.
MergeSort(int numberOfInts, java.lang.String serverName, int maxIntValue, java.lang.String spaceName, int numberOfSortThreads)
          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

MergeSort

public MergeSort()
Sort a set of randomly generated integers.

MergeSort

public MergeSort(int numberOfInts)
Sort a set of randomly generated integers.
Parameters:
numberOfInts - the number of random integers to generate and then sort.

MergeSort

public MergeSort(int numberOfInts,
                 java.lang.String serverName)
Sort a set of randomly generated integers.
Parameters:
numberOfInts - the number of random integers to generate and then sort.
numberOfSortThreads - the number of threads to be used to sort the the integers. Each one will make its own accesses to the TupleSpace.

MergeSort

public MergeSort(int numberOfInts,
                 java.lang.String serverName,
                 int maxIntValue)
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.
numberOfSortThreads - the number of threads to be used to sort the the integers. Each one will make its own accesses to the TupleSpace.

MergeSort

public MergeSort(int numberOfInts,
                 java.lang.String serverName,
                 int maxIntValue,
                 java.lang.String spaceName)
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.
numberOfSortThreads - 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.

MergeSort

public MergeSort(int numberOfInts,
                 java.lang.String serverName,
                 int maxIntValue,
                 java.lang.String spaceName,
                 int numberOfSortThreads)
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.
numberOfSortThreads - 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.