I'm just now learning the concepts of threads.....I tried to execute this pgm : class td{ public static void main(String args[]){ Thread t=Thread.currentThread(); System.out.println("current thr " +t); System.out.println("after name change "); try{ for(int i=5;i>5;i--){ System.out.println(i); t.sleep(1000); } }catch (InterruptedException e){ System.out.println("main thread interrupted"); } } } But as expected, the pgm had to print the numbers 1,2,3,4 and 5, in an interval of 1 sec between each number, but it didn't print. The output just stopped with the print of "after name change ". Why doesn't that print the numbers??
Hi, loop is not coded as expected. you can code it like "for(int i=5;i<=1;i--)". hope it helps regds George George, We all make mistakes. It will be helpful if we help others rectify their mistakes. I have modified your message to remove inappropriate content.
[This message has been edited by Rahul Mahindrakar (edited January 28, 2001).]
Peter den Haan
author
Ranch Hand
Joined: Apr 20, 2000
Posts: 3252
posted
0
loop is not coded as expected. you can code it like "for(int i=5;i<=1;i--)". <br />
<br /> might work better. - Peter Peter , I have removed content that i feel is inappropriate.
[This message has been edited by Rahul Mahindrakar (edited January 28, 2001).]
George Toronto
Ranch Hand
Joined: Dec 30, 2000
Posts: 78
posted
0
Oh, I am sorry, it is a type error. Thank you for correcting it.