Can someone please explain how to do this.
So your problem has more solutions but nicely from the beginning. I suggest you to create own subclass of Thread and pass parameter via its constructor.
public class MyThread extends Thread {
public MyThread(String value) {
}
}
Or you can also use Runnable interface as well.
public class MyThread implements Runnable { ... }
Update:
Or like @erickson pointed out you can wrap your code into body of method but as method's argument you have to pass final variable because you cannot cannot refer to a non-final variable inside inner class defined in a different method.