Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread - run() constructor

 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can an argument be passed to run() method of thread like run( int i ) and through which method the value can be passed to its variable i because we don't call thread method run() instead it is called through start() method.
Here is the scenario:
class A implements Runnable and it's initialized in class Thread's constructor with the value of argument declared in run(int i) method.
Please clarify.
thanks and best regards
Rashid Ali
 
anand raman
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
You cant pass in a parameter to the run method, because if you do so in the code, you will end up overloading the method rather than overriding it.
-Anand
 
Rashid Ali
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much for your quick reply.
It suffice my querry.
Kind regards
Rashid Ali
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic