How to execute a method outside of a thread in which a dependent parameter is in

Tauredummed

New Member
Assume a generic method, i.e. \[code\]sayHello(a)\[/code\], takes argument \[code\]str\[/code\] as a formal parameter.\[code\]new Thread(new Runnable() { @Override public void run() { String str = "Hello World"; sayHello(str); } }).start();\[/code\]I need to execute \[code\]sayHello(str)\[/code\] outside of this thread (or more importantly, inside the main thread), however \[code\]String str = "Hello World";\[/code\] must be executed within this new thread. So, how would I go about solving this problem?
 
Back
Top