Answers for "set timeout java"

28

javascript settimeout

setTimeout(function(){ alert("Hello"); }, 3000);
Posted by: Guest on September-13-2019
0

timeout java

ExecutorService executor=Executors.newSingleThreadExecutor();
Future<ReturnType> future=executor.submit(task);
try{
	ReturnType result=future.get(1,TimeUnit.SECONDS);
	//task successful
}catch(TimeoutException e){
	//timeout
	future.cancel(true);
}catch(InterruptedException e){
	//current thread was interrupted during task execution
	Thread.currentThread().interrupt();
}catch(ExecutionException e){
	//task threw Exception
	throw e.getCause();
}
Posted by: Guest on April-06-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language