J
junzhang1983
3ks
I hope now you see why you should echo your question in the body of
I hope now you see why you should echo your question in the body of
your post.
Try it. run is your method. Nothing exciting will happen. It will
just execute your method on the current thread. When you call start,
it execute's Sun's code that does the magic of creating a new thread,
then calling run on it.
Seehttp://mindprod.com/jgloss/thread.html
first ,thanks you answer,but l still have a little problem
for example:
class A{
void testThread(){
MyThread thread = new MyThread();
//we often call thread .start(),not thread.run() to run a
thread,
//now that l am already create a new Thread above,
//why l need call sun's code which is method start()
// to create a new thread?why call run() is not ok?
}
}
class MyThread extends Thread{
public void run(){
//do something
}
}
first ,thanks you answer,but l still have a little problem
I also suggest having a look at the source code for run and start.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.