myBtn.setEnabled(false);
ExecutorService executor = Executors.newFixedThreadPool(10);
Runnable runnableTask = () -> {
try {
TimeUnit.MILLISECONDS.sleep(2000);
myBtn.setEnabled(true);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
executorService.execute(runnableTask);