tags:

views:

15

answers:

0

guys the following code does not wiat for the thread t to complete and join with the main thread, also the "created object" trace is called one more time after join is called please let me know the solution

<%
  AProc empList = new AProc();      
    System.out.println("******** Created Object **********");
    System.out.println("Condition"+(!(p.length==0) && !(status) && !(threadLive)));
    if (!(p.length==0) && !(status) && !(threadLive)){
       java.util.Date currDate = new java.util.Date();
           try {
         Thread t = new Thread(empList);
         System.out.println("Check thread life 1 "+t.isAlive());
         empList.setServletRequest(request , schemaName);
         System.out.println("Thread Started "+t);
         t.start();
         System.out.println("Check thread life 2 "+t.isAlive());
         if(t.isAlive()) {
           threadLive = true;
         }
         t.join();
         while (t.isAlive())
         {
             t.join();
         }   
         System.out.println("Check thread life 3 "+t.isAlive());
         System.out.println("Thread End "+t);
         //}
       } catch (Exception e) {
          System.out.println("Exception in thread while running Procedure "+e); 
          status=false;
          threadLive=false;
       }
       status = e.getStatusProc();

    }%>