how to pass parameter to thread ?? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

how to pass parameter to thread ??

27th Dec 2016, 1:40 PM
ayoub
ayoub - avatar
2 ответов
0
You need to pass the parameter in the constructor to the thread object: public class MyThread implements Runnable { public MyThread(Object parameter) { // store parameter for later user } public void run() { } } and invoke it this: Runnable r = new MyThread(param_value); new Thread(r).start();
27th Dec 2016, 2:23 PM
guizani mahmoud
guizani mahmoud - avatar
0
thank you bro
29th Dec 2016, 1:43 PM
ayoub
ayoub - avatar