Hi everybody, I am Krishna, I have written this code on Threads, I don't know why this is not working, it is not giving a compile time error or run time error. The run() is not being executed.
The code is
Can anybody tell me what is wrong in this code. Thanks in advance. Have a nice day.
There is no rule that we all should know everything. Lets learn few things of everything here.
Hi Dittmer, I removed that lines and executed it again, but the run method is not being executed.
The output is 0123456789 with a delay of 500 milliseconds
You must start() your anonymous NewThread object.
How are you learning about threads?
Jim ... ...
BEE MBA PMP SCJP-6
Christian Dillinger
Ranch Hand
Joined: Jul 20, 2009
Posts: 172
posted
0
Jim Hoglund wrote:You must start() your anonymous NewThread object.
NewThread is a Runnable so he cannot call start().
krishna Karthikk
Ranch Hand
Joined: Mar 16, 2010
Posts: 92
posted
0
The code is now executing, I missed this one
Christian Dillinger
Ranch Hand
Joined: Jul 20, 2009
Posts: 172
posted
0
That's a very uncommon use of threads. I'd recommend using the normal way... If you come to the chapter "executors" you'll understand why you should...
Jim Hoglund
Ranch Hand
Joined: Jan 09, 2008
Posts: 525
posted
0
Good point. Is it working now? If you wish, you
can post the entire program again for review.
Jim ... ...
krishna Karthikk
Ranch Hand
Joined: Mar 16, 2010
Posts: 92
posted
0
This is the correct code. Let em know it is efficient or not.