Multi-Threaded Sorting Example

by Eric Bergerson

This example project demonstrates using multiple threads to simultaneously sort a common Vector . In this case the Vector has to contain elements that are Comparable .

If everything is running as it should, you should see an applet below with a series of vertical lines of all different heights. This is a graphic representation of the random vector to be sorted. If you see only a blank square, then you are probably running an old version of the JRE. This applet requires JRE 1.3.

To start run the example, just click on the applet below. To restart the applet, refresh the page.
If you can read this, then you either have a non-java browser or you need to turn java support on in your options to allow this applet to run.
*Note: Links to the source code are available from within the documentation in the description section of each class.

Alternatively, you can download and run this example as a java application using Java Web Start. If you are on Mac OS X 10.1+, the software you need is already installed. However, if you are on Windows or some other OS, yo may need to download the Java Web Start software ( Windows ).

Run the Thread Sort application.

Future Goals

The current SortApplet extends java.applet.Applet. I would like to re-write this entirely from scratch, extending instead, javax.swing.JApplet. I am hoping that in migrating to JApplet, I will reach the following goals:
  1. Determine a rough estimate of the performance hit for using swing instead of awt.
  2. Start expanding the applet, to include controls for modifying the size of the vector and number of threads. While, strictly speaking, this can be done inside Applet as well, I personally want the experience of working with JApplet.
  3. I am hoping that work at getting this over to JApplet, will also reduce the amount of work to reach my final goal, of having this be a standard stand-alone swing application deliverable by Java Web Start.

If you have any questions or comments, please don't hesitate to contact me. I hope you found this project stimulating.


Eric Bergerson

Copyright (c) Objective Technologies, Inc. All rights reserved.

This project is composed of software having different rightful owners. Please refer to the license agreements in the source code to understand limitations on its use.

Of course, Objective Technologies, Inc. and its stockholders do not warrant, guarantee, or otherwise assume any responsibility or accountability for any loss, damage, corruption, or consequences caused by the use or distribution of the software or related materials available in this project. If something bad happens as a result of using this software, it's your own fault for using it. Please report any problems to