Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why this does not fail?  RSS feed

 
Brian Smith
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi folks,

i thought the program would fail compiling as we can not invoke run()method directly. but it works fine. WHY?
I would appreciate if someone explains me.
thanks.
[ July 29, 2003: Message edited by: Namaste Sathi ]
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's nothing preventing you from calling run: it is delared as public. The Thread class's run method does nothing (unless it was created with a Runnable object); but in your subclass here, it does do something.
 
Brian Smith
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joel,
so it's not necessary true that we can't invoke run() method of a Thread directly. And also, we can't predict when the run()method gets excuted once the start() is invoked. right?
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you invoke the run() method then it is not running as a separate thread. run() is no different than any other method when invoked that way.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!