• Post Reply Bookmark Topic Watch Topic
  • New Topic

thread doesn't seem to be work?  RSS feed

 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is my class


but it doesn't print "System.out.println("inside main method inside main method inside main method ");" line in main method.Why?
 
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Threads are not restartable. Only the first loop will run, upon the second loop, the start() method will throw an exception.

Henry
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.But why it doesn't give exception then?
let's assume after line number 16 main thread stop and t1 thread it goes to run.
then after 28 line t1 thread stop and main thread going to strat.
then it could start t1 again?
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, what output do you get?
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that it hasn't scrolled off? The other threads are endless loops, so the one message, along with any exceptions messages, quickly disappear as the screen buffer overflows.

Henry
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what do you mean hasn't scrolled off?
I put only part of the message.Because i start the programm and stop as soon as posible.But it prints more than 1000 lines.

 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks similar to the output I got when I tried your class. Henry is correct; it has probably disappeared when scrolling. If you get 1000 lines, your command line/terminal will lose all the previous lines. They will vanish too quickly for you to catch.
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no i am using eclips.so i can many lnes.But i can't guarntee see all lines.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eclipse behave the same way -- the output screen can overflow just like a command terminal. You will need to slow the output from the other threads a bit, if you want to see the output from the main thread.

Henry
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!