class bubblesort implements Runnable{
int ar[] = new int[10000];
Thread td;
bubblesort(){
int t=0;
for(int i=9999;i>0;i--){
t++;
ar[t]=i;
}
td=new Thread(this,"Gow");
td.start();
}
public void run(){
int t;
for(int i=0;i<9999;i++){
for(int j=0;j<9999-i;j++){
if(ar[j]>ar[j+1]){
t=ar[i];
ar[i]=ar[j+1];
ar[j+1]=t;
}
}
}
System.out.println("Done");
}
}
class selsort implements Runnable{
int ar[] = new int[10000];
Thread td;
selsort(){
int t=0;
for(int i=9999;i>0;i--){
t++;
ar[t]=i;
}
td=new Thread(this,"Gow1");
td.start();
}
public void run(){
int t;
int min=0;
for(int i=0;i<9999;i++){
min=i;
for(int j=i+1;j<10000;j++){
if(ar[j]<ar[min])
min=j;
}
t=ar[i];
ar[i]=ar[min];
ar[min]=t;
}
System.out.println("Done2");
}
}
class check{
public static void main(String args[]){
new bubblesort();
new selsort();
}
}
compile as javac check.java
run as java check
0 comments:
Post a Comment