Asynchronous call in Java
int i = 5;
Runnable action = () -> {
try {
Thread.sleep(3000);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(i * 10);
};
//Run lambda at new thread
Thread thread = new Thread(action);
thread.start();
- Log in to post comments