KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > lang > IllegalMonitorStateException

java.lang
Class IllegalMonitorStateException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by java.lang.IllegalMonitorStateException
All Implemented Interfaces:
Serializable
See Also:
Top Examples, Source Code, Object.notify(), Object.notifyAll(), Object.wait(), Object.wait(long), Object.wait(long, int)

public IllegalMonitorStateException()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[492]Illegal monitorStateExcepiton in the wait
By miquil69 { at } hotmail { dot } com on 2004/12/20 14:01:57  Rate
while ( t.getT2isFinished (  )  == false )  
  {  
   try 
    {  
     JOptionPane.showMessageDialog ( null,"client 1 is waiting" ) ; 
                 wait (  ) ; 
  
  
              }  
             catch ( IllegalMonitorStateException e )  
              {  
               JOptionPane.showMessageDialog ( null,"problem with wait1" ) ; 
                  }  
             catch ( InterruptedException e )  
              {  
                   JOptionPane.showMessageDialog ( null,"problem with wait2" ) ; 
                  }  
            }  
           notifyAll (  ) ; 
           JOptionPane.showMessageDialog ( null,"client 1 is finished waiting" ) ;


[1496]_
By rajudatar { at } hotmail { dot } com on 2005/07/25 17:28:38  Rate
I always get teh Illegal monitorStateExcepiton in the wait. 
 What could be the problem? I want to create threads in teh main program and wait, collect stats from threads and then do this till someone clicks the stop button or hits control-C. 
 Thanks a lot in advance. Regards, 
 while  ( true )   {  
             try  {  
                 wait (  ( 60 * 1000 )  ) ; // wait 60 seconds. Should be what user chooses. 
                 printThreadCounters (  ) ; 
              }  
             catch  ( InterruptedException ie )   {  
                 System.err.println ( "MAIN THREAD INTERRUPTED: " + ie ) ; 
              }  
             catch  ( IllegalMonitorStateException iese )   {  
                 System.err.println ( "MAIN THREAD INTERRUPTED: " + iese ) ; 
                 System.exit ( 1 ) ; 
              } 


public IllegalMonitorStateException(String s)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags