Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class App {
- public static void main(String[] args) {
- ExecutorService executor = Executors.newCachedThreadPool();
- executor.submit(new Runnable() {
- public void run() {
- Random random = new Random();
- int duration = random.nextInt(4000);
- System.out.println("Starting ... ");
- try {
- Thread.sleep(duration);
- } catch (InterruptedException ex) {
- Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
- }
- System.out.println("Finished ... ");
- }
- });
- executor.shutdown();
- }
- }
Add Comment
Please, Sign In to add comment