Assume I would like to pass the following variable
String foo = "hello world";
as an argument to the following thread
new Thread(new Runnable() {
    @Override
    public void run() {
        // SOME CODE HERE REQUIRES VARIABLE
    }
}).start();
Can someone please explain how to do this.
Thanks.
Subclass Thread:
public class MyThread extends Thread {
   private String arg;
   public MyThread(String arg) {
      this.arg = arg;
   }
   @Override
   public void run() {
        // Use your variable
   }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With