Can someone explain how to do this.
So your problem has more solutions, but from the very beginning. I suggest you create your own subclass of Thread and pass the parameter through the constructor .
public class MyThread extends Thread { public MyThread(String value) { } }
Or you can also use the Runnable interface.
public class MyThread implements Runnable { ... }
Update:
Or as @erickson pointed out that you can wrap your code in the body of the method, but as an argument to the method you must pass a final variable, because you cannot but refer to a non-final variable inside the inner class defined by another method.
source share