多线程实现排序:总是提示main函数有问题 另外如果数组先不给定,如何实现
import java.io.*;
public class pai 
{
   
   public static void main(String args[])
   { 
      
      bigtosmall btos=new bigtosmall("btos");
      smalltobig stob=new smalltobig("stob"); 
      Thread  t1 = new Thread (btos);
      Thread  t2 = new Thread (stob);
      new Thread (btos).start(); 
      new Thread (stob).start();   
   }
}class bigtosmall implements Runnable{
    int a[]={1,33,25,14,42,86,58,37,69,10}; 
 private String id;
   public bigtosmall(String str)
   {   
    id=str;
  }   
   public void run()
   {
    int i,j=0;
      for( i=0;i<9;i++)
        for(j=i+1;j<10;j++); 
         {
          if(a[i]<a[j])
         {
         int temp=a[i];
          a[i]=a[j];
          a[j]=temp;
          }
         }
        for(int k=0;k<10;k++) 
       System.out.println(a[k] ) ;
      
      } 
   }///////////////
class smalltobig implements Runnable
{
     int a[]={1,33,25,14,42,86,58,37,69,10}; 
  private String id;
   public smalltobig(String str)
   {   
    id=str;
  }   
   public void run()
   {
    int i, j;int temp=a[0];
      for( i=0;i<9;i++)
      {
         for( j=i+1;j<10;j++); 
         {
          if(a[i]>a[j])
          {
          temp=a[i];
          a[i]=a[j];
          a[j]=temp;
          }
         }
        
       System.out.println("the result is :");
       for(int k=0;k<10;k++) 
       System.out.println(a[k]+" " ) ;
        
      } 
   }   
}

解决方案 »

  1.   

    import java.io.*;
    public class pai 
    {
       
       public static void main(String args[])
       { 
          
          bigtosmall btos=new bigtosmall("btos");
          smalltobig stob=new smalltobig("stob"); 
          Thread  t1 = new Thread (btos);
          Thread  t2 = new Thread (stob);
          new Thread (btos).start(); 
          new Thread (stob).start();   
       }
    }class bigtosmall implements Runnable{
        int a[]={1,33,25,14,42,86,58,37,69,10}; 
     private String id;
       public bigtosmall(String str)
       {   
        id=str;
      }   
       public void run()
       {
        int i,j=0;
          for( i=0;i<9;i++)
            for(j=i+1;j<10;j++)       // 去掉分号 
             {
              if(a[i]<a[j])
             {
             int temp=a[i];
              a[i]=a[j];
              a[j]=temp;
              }
             }
            for(int k=0;k<10;k++) 
           System.out.println(a[k] ) ;
          
          } 
       }///////////////
    class smalltobig implements Runnable
    {
         int a[]={1,33,25,14,42,86,58,37,69,10}; 
      private String id;
       public smalltobig(String str)
       {   
        id=str;
      }   
       public void run()
       {
        int i, j;int temp=a[0];
          for( i=0;i<9;i++)
          {
             for( j=i+1;j<10;j++) // 去掉分号 
             {
              if(a[i]>a[j])
              {
              temp=a[i];
              a[i]=a[j];
              a[j]=temp;
              }
             }
            
           System.out.println("the result is :");
           for(int k=0;k<10;k++) 
           System.out.println(a[k]+" " ) ;
            
          } 
       }   
    }
      

  2.   

    对于不定数组:import java.io.*;
    public class pai 
    {
       
       public static void main(String args[])
       { 
         
          int[] a1 =  {1,33,25,14,42,86,58,37,69,10};
          int[] a2 =  {1,33,25,14,42,86,58,37,69,10};
          bigtosmall btos=new bigtosmall("btos",a1);
          smalltobig stob=new smalltobig("stob",a2); 
          Thread  t1 = new Thread (btos);
          Thread  t2 = new Thread (stob);
          new Thread (btos).start(); 
          new Thread (stob).start();   
       }
    }class bigtosmall implements Runnable{
        int[] a; 
     private String id;
       public bigtosmall(String str ,int[] a)
       {   
        id=str;
        
        this.a = a;
      }   
       public void run()
       {
        int i,j=0;
          for( i=0;i<a.length - 1;i++)
            for(j=i+1;j<a.length ;j++)       // 去掉分号 
             {
              if(a[i]<a[j])
             {
             int temp=a[i];
              a[i]=a[j];
              a[j]=temp;
              }
             }
            for(int k=0;k<a.length;k++) 
           System.out.println(a[k] ) ;
          
          } 
       }///////////////
    class smalltobig implements Runnable
    {
         int[] a  ; //={1,33,25,14,42,86,58,37,69,10}; 
      private String id;
       public smalltobig(String str ,int[] a)
       {   
        id=str;
        
        this.a = a;
      }   
       public void run()
       {
        int i, j;int temp=a[0];
          for( i=0;i<a.length - 1;i++)
          {
             for( j=i+1;j<a.length ;j++) // 去掉分号 
             {
              if(a[i]>a[j])
              {
              temp=a[i];
              a[i]=a[j];
              a[j]=temp;
              }
             }
            
           System.out.println("the result is :");
           for(int k=0;k<a.length;k++) 
           System.out.println(a[k]+" " ) ;
            
          } 
       }   
    }
      

  3.   

    非常感谢这位仁兄,我想是我的jcreator有问题。不过我想要的是随机输入一些数,然后排序输出。