Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #8669

Re: java Thread class

From Knute Johnson <nospam@knutejohnson.com>
Newsgroups comp.lang.java.programmer
Subject Re: java Thread class
Date 2011-10-09 20:20 -0700
Organization A noiseless patient Spider
Message-ID <j6toan$tbr$1@dont-email.me> (permalink)
References <319384c2-13c3-45f1-a9be-2be669a2204b@r8g2000prh.googlegroups.com>

Show all headers | View raw


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

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

java Thread class 光 署 <shuguang008@gmail.com> - 2011-10-09 20:07 -0700
  Re: java Thread class Knute Johnson <nospam@knutejohnson.com> - 2011-10-09 20:20 -0700
  Re: java Thread class Patricia Shanahan <pats@acm.org> - 2011-10-09 20:37 -0700

csiph-web