I do in fact write the data to the thread's constructor but to get it into the run method (which takes no parameters) of the thread I need to store the data in class level variables to make it available.
But once you send it to the constructor, you should save the data inside local variables. And after calling start, your thread will be able to reach them via local variables. Am i missing something?
The code will be sth like this:
class MyThread extends Thread {
private String myData1;
private int myData2;
public MyThread(String myData1, int myData2) {
this.myData1 = myData1;
this.myData2 = myData2;
}
public void run() {
// Use your local variables here now
System.out.println(myData1);
}
}