import java.util.*;
import java.lang.*;
import java.util.concurrent.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
        System.out.println("Before");
        ExecutorService executorService = Executors.newFixedThreadPool(1);
		FutureTask<Object> futureTask = new FutureTask<Object>(new Runnable() {
            public void run()
            {
                System.out.println("Hello async world!");
            try
            {
                    Thread.sleep(1000);
            }
            catch (InterruptedException interruptedException)
            {
                System.out.println("Err: " + interruptedException);
            }
                System.out.println("I'm finally done");
            }
		}, null);
        System.out.println("Defined");
        System.out.println(new Date());
        executorService.execute(futureTask);
        System.out.println("Running");
        System.out.println(new Date());
        while (!futureTask.isDone())
        {
            System.out.println("Task not yet completed.");

            try
            {
                    Thread.sleep(300);
            }
            catch (InterruptedException interruptedException)
            {
            }
        }
        System.out.println("Done");
        System.out.println(new Date());
	}
}