응용 프로그램 java 및 장면 빌더를 수행 중이므로 newScheduledThreadPool(1)
을 작성합니다. 버튼을 클릭하면 다음에 버튼을 다시 클릭하면 실행 프로그램이 일시 중지되어야하고 버튼을 다시 클릭하면 실행 프로그램이 다시 시작됩니다. newScheduledThreadPool을 일시 중지하는 방법은 무엇입니까?
이
내 코드입니다 : 대한public class ExecutorThreadReadDatabase {
static Logger logger = MyLog4J.getInstance();
private static boolean stopThread ;
private static ExecutorThreadReadDatabase executorThreadReadDatabase;
private ScheduledExecutorService executor;
public ExecutorThreadReadDatabase() {
executor = Executors.newScheduledThreadPool(1);
}
public static ExecutorThreadReadDatabase getInstance() {
if (executorThreadReadDatabase == null) {
logger.info("null");
return new ExecutorThreadReadDatabase();
} else {
logger.info("not nullo");
return executorThreadReadDatabase;
}
}
public void readToDatabaseFromNetworkServer() {
logger.info("lo stop è : "+stopThread);
executor.scheduleAtFixedRate(RunnableThread.getInstance(), 0, 5,
TimeUnit.SECONDS);
}
public void stopT() {
logger.info("stoppo l' executor");
executor.shutdown();
executor.wait()
}
죄송합니다 나의 나쁜 영어
"잠시 멈추다"라는 뜻은 무엇입니까? 예정된 실행을 건너 뛰는 것을 의미합니까? –
예, 다시 버튼을 누르기 전까지 –