Javaで次のようなことができますか:
protected Runnable getRunnable(final int seconds) {
Runnable runnable = new Runnable() {
public void run() {
sendData();
try {
Thread.sleep(seconds * 1000);
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
};
return runnable;
}
その後:
protected void startTimer(int seconds) throws InterruptedException,NullPointerException {
Thread thread = new Thread(getRunnable(seconds));
thread.start();
}
前述のプロセスは安全ですか??