---
title: "IllegalThreadStateException 产生原因"
author: "aty"
date: "2013-11-21T13:46:35Z"
tags: []
categories: ["编程语言"]
slug: "illegalthreadstateexception"
draft: false
lastmod: "2013-11-21T13:46:35Z"
id: 1978402
url: "https://aty.iteye.com/blog/1978402"
---

1、对一个线程调用2次以上的start()方法会报错。

ChildThread t1 = new ChildThread("thread1");     
 t1.start();  
 t1.start();

 

2、对于已经启动的线程,调用setDaemon会报错

 

class ChildThread extends Thread  
 {

  @Override  
  public void run()  
  {  
   System.out.println(this.name + "--child thead begin");

   setDaemon(false);  
  }  
 }