package com.huang;
public class Sort {
/**
* @param args
*/
//冒泡排序
static class bubblesort extends Thread{
public int a[]= {3,8,6,4,9,7,12,88,55,1,2,66};
private String name;
public bubblesort(String name){
this.name=name;
}
public void run(){
for(int i=1;i<a.length;i++){
for(int j=0;j<a.length-i;j++){
if(a[j]<a[j+1]){
int temp = a[j];
a[j]=a[j+1];
a[j+1] = a[j];
System.out.println("当前运行的线程为:"+name+a[j]);
}
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
bubblesort bubblesort1 = new bubblesort("线程1-");
bubblesort bubblesort2 = new bubblesort("线程2-");
bubblesort bubblesort3 = new bubblesort("线程3-");
bubblesort1.start();
bubblesort2.start();
bubblesort3.start();
}
}
}