본문 바로가기
IT/JAVA

IllegalThreadStateException 발생 원인

by honeybear 2014. 3. 16.

아래와 같은 에러가 발생할 경우

Exception in thread "main" java.lang.IllegalThreadStateException
      at java.lang.Thread.start( Thread.java:571 )
      at com.test.test.go( test.java:24 )
      at com.test.test.main( test.java:28 )


Thread의 상태가 비적합할 경우 나타나는 에러 메시지로 

하나의 Thread 객체에 start()를 두번 이상 호출을 할 경우 발생한다.


예를 들어


t 라는 스레드 객체에 대해 start()를 두 번 호출을 할 경우 발생이 된다.



Thread Class의 소스를 보면 해당 Thread 객체가 시작이 되면 상태가 되고 한번 더 호출을 할 경우 예외를 발생시킨다.




댓글