次のコードがあります。
public class Shell {
String status;
Runtime rtime;
Process process;
public void runCmd(final String cmd,String status) throws Exception{
this.status = status;
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
process = rtime.exec(cmd);
process.waitFor();
this.status = "check out done";
} catch (IOException e) {
} catch (InterruptedException e) {
}
}
});
t.start();
}
}
しかし、Java では、新しいスレッド t 内の変数を変更することはできません。status
ある種のスレッド間通信が必要なのかもしれません。スレッドが初めてなので、これを行う方法を教えてください。