public Class TestSortingPerformance { public static void main(String[] args) { new Thread() { public void run() { sort1(); } }.start(); new Thread() { public void run() { sort2(); } }.start(); new Thread() { public void run() { sort3(); } }.start(); }
public static void main(String[] args) {
new Thread() {
public void run() {
sort1();
}
}.start();
new Thread() {
public void run() {
sort2();
}
}.start();
new Thread() {
public void run() {
sort3();
}
}.start();
}
static void sort1() {
long t1 = System.currentTimeMillis();
//Do sort
/**implement sorting*/
long segment = System.currentTimeMillis() - t1;
System.out.print("Sort Method 1 cost :" + segment + " milseonds.");
}
}
如果线程要调度或者排序方法的增加之类的实现另行设计了,呵呵
public static void main(String[] args) {
//生成随机数
final int[] nums = genRandomInt(10000);然后
new Thread(){
public void run() {
sortInt1(nums);
}
}.start(); 当然
static void sort1(){ 变成 static void sortInt1(int[] rand)