Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Knute Johnson Newsgroups: comp.lang.java.programmer Subject: Re: java Thread class Date: Sun, 09 Oct 2011 20:20:53 -0700 Organization: A noiseless patient Spider Lines: 36 Message-ID: References: <319384c2-13c3-45f1-a9be-2be669a2204b@r8g2000prh.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 10 Oct 2011 03:20:56 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="mz/LDSJwiWnk3Jnnqg7x+Q"; logging-data="30075"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+nrXSyIT5iQWDaMpkomdaZ" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 In-Reply-To: <319384c2-13c3-45f1-a9be-2be669a2204b@r8g2000prh.googlegroups.com> Cancel-Lock: sha1:bA8lVvRh6cUXtc8XDR1ogOQF3RU= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8669 On 10/9/2011 8:07 PM, 光 署 wrote: > hi all, I have a Thread named r1 , why I can not write " > r1.start();r1.start();". when I write "r1.start(); r1.start();" there > was an error that "IllegalThreadStateException". > > r1.run(){ > public void run(){ > System.out.println("name" + super.getName() + "---->" + > super.getI()); > } > } start public void start() Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread. The result is that two threads are running concurrently: the current thread (which returns from the call to the start method) and the other thread (which executes its run method). It is never legal to start a thread more than once. In particular, a thread may not be restarted once it has completed execution. Throws: IllegalThreadStateException - if the thread was already started. See Also: run(), stop() -- Knute Johnson