Programming Resources
For Fun and Learning
Charles Cusack
Computer Science
Hope College
main

Python
C++

JAVA


PHP
SQL
Assignments

ThreadExamples


SortThread.java

package basicExamples;
public class SortThread extends Thread {
	int[]		array;
	int			l, r;

	public SortThread(int[] array, int l, int r) {
		super();
		this.array = array;
		this.l = l;
		this.r = r;
	}

	public void run() {
		bubblesort(array, l, r);
	}

	void bubblesort(int A[], int l, int r) {
		for (int i = r; i >= l; i--) {
			for (int j = l; j < i; j++) {
				if (A[j] > A[j + 1]) {
					swap(A, j, j + 1);
				}
			}
		}
	}

	public void swap(int[] A, int i, int j) {
		int temp = A[i];
		A[i] = A[j];
		A[j] = temp;
	}
}