title: Thread Synchronization can't work
body: <p>i need help, i try to use synchronization thread in java but it can't run...</p>
  
  <p>i have two class with thread like this</p>
  
  <pre><code>for(int j=0;j&lt;idW.length;j++){
              webtext = d.getWebText(idW[j]); 
              ThreadPrepo tpo =new ThreadPrepo(webtext, host[j%jumhost], "server", 1099,idW[j]);  
              Thread t1=new Thread(tpo);
              t1.start();
          }
          //thread untuk setfitur tanpa rmi
          int ukuran=idW.length;
          ProsesSetfitur pro=new ProsesSetfitur(idW);
          Thread t2=new Thread(pro);
          t2.start();
  </code></pre>
  
  <p>this is the code in class threadprepo :</p>
  
  <pre><code>public class ThreadPrepo implements Runnable{
      String host,server,c,webtext;
      int port,idweb;
      DataDB db=new DataDB();
      public  ThreadPrepo(String webtext,String host,String server,int port,int idweb){
          this.webtext=webtext;
          this.host=host;
          this.server=server;
          this.port=port;
          this.idweb=idweb;    
      }
      @Override
      public void run(){
         preponi();
      }
  
      public synchronized void preponi(){
          try{
             System.out.println("hostnya :"+host);
              Registry reg=LocateRegistry.getRegistry(host,port);
              Sportrmijob rmi=(Sportrmijob) reg.lookup("server");
              rmi.SetInput(webtext);
              List l=rmi.getresult();
              String[] hasilprep=new String[l.size()];
              for(int k=0;k&lt;l.size();k++){
                  hasilprep[k]=l.get(k).toString();          
             }
             db.insertWordney(idweb, hasilprep);       
             String [][] frekdb=db.getFrekDB(idweb);
             db.doinsertfrek(idweb,frekdb);
  
      }
          catch(Exception e){
              System.out.println("error di class threadprepo "+e.getMessage());
          }
      }
  
  }
  </code></pre>
  
  <p>and then this is code in class prosesSetFitur</p>
  
  <pre><code>public class ProsesSetfitur implements Runnable{
      DataDB d=new DataDB();
      int []idweb;
  
      public ProsesSetfitur(int[]idweb){  
          this.idweb=idweb;
     }
  
      @Override
        public void run(){
        try{
            Thread.sleep(500);
            setfitur();
        }
        catch(Exception e){
             System.out.println("error setfitur "+e.getMessage());        
         }
      }
      public synchronized void setfitur() throws InterruptedException{     
  
         System.out.println("(proses setfitur)");  
         String []allkata;
         String fitur;
         String []fiturs=new String[15];
         String []kata_kata=new String[15];
          System.out.println("nilai iD="+idweb.length);
         for(int s=0;s&lt;idweb.length;s++){
              //System.out.println("IDWEEEEEEEEEEB"+idweb[s]);
              allkata=d.getUrutanKata(idweb[s]);  
              for(int u=0;u&lt;15;u++){
                 // System.out.println("PERULANGAN U KE"+u);
                  if(u&lt;=4){
                      fitur="T";
                      //System.out.println("kata ke" +u+" = "+allkata[u]+" fiturnya = "+fitur);
                      kata_kata[u]=allkata[u];
                      fiturs[u]=fitur;
                  }
                  else if(u&gt;4&amp;&amp;u&lt;10){
                      fitur="S";
                      //System.out.println("kata ke"+u+" = "+allkata[u]+" fiturnya = "+fitur); 
                      kata_kata[u]=allkata[u];
                      fiturs[u]=fitur;
                  }
                  else if(u&gt;=10&amp;&amp;u&lt;15){
                     fitur="R" ;
                     //System.out.println("kata ke"+u+" = "+allkata[u]+" fiturnya = "+fitur); 
                     kata_kata[u]=allkata[u];
                     fiturs[u]=fitur;
                  }
              }
              d.insertfitur(idweb[s], kata_kata, fiturs);
        } 
        }
  </code></pre>
  
  <p>can anyone give me solution to solve this problem...why thread in class ProsesSetFitur is execute first?how synchronization thread can work?please help...</p>