sathya88
0
Junior Poster in Training
Recommended Answers
Jump to PostIf you are using another class
…public class Constructor_benifit{ public static void main(String[] args){ System.out.println("In primary Thread"); A a=new A("Test string for secondary thread"); Thread thread_object=new Thread(a); thread_object.start(); } } class A implements Runnable { String to_print; A(String to_print){ this.to_print=to_print; } public void run(){ System.out.println(to_print); } }
Jump to PostSee http://stackoverflow.com/questions/877096/java-threading-pass-parameter-to-a-thread
It pretty much boils down to these choices:
1. Pass them to the constructor of your Thread/Runner class.
2. If you're using anonymous inner classes, make variables in the enclosing …
All 8 Replies
LevyDee
2
Posting Whiz in Training
Muralidharan.E
14
Junior Poster in Training
JeffGrigg
170
Posting Whiz in Training
Muralidharan.E
14
Junior Poster in Training
NormR1
563
Posting Sage
Team Colleague
JeffGrigg
170
Posting Whiz in Training
NormR1
563
Posting Sage
Team Colleague
Muralidharan.E
14
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.