/**
 * Thread class for sorting an array using concurrent MergeSort
 *   @author Dave Reed
 *   @version 4/12/17
 */
public class SortThread extends Thread {
	private int[] nums;
	private int minIndex;
	private int maxIndex;
	private int threadCount;
	
	/**
	 * Constructs a SortThread to sort the numbers within a range.
	 * @param nums the array of numbers
	 * @param minIndex minimum index of the range
	 * @param maxIndex maximum index of the range
	 * @param threadCount number of threads that can be spawned
	 */
	public SortThread(int[] nums, int minIndex, int maxIndex, int threadCount) {
		this.nums = nums;
		this.minIndex = minIndex;
		this.maxIndex = maxIndex;
		this.threadCount = threadCount;
	}

	/**
	 * Overrides the default run method from Thread.
	 * In this case, sorts the numbers in the range within an array.
	 */
	public void run() {
		MergeSort.mergeSortConcurrently(this.nums, this.minIndex, this.maxIndex, this.threadCount);
	}
}