Question: I need to create MySQL database from terminal or CMD. I have tried this command.

```
CREATE DATABASE something

```

Answer: 
To know about the task status - You need Future instance.
Now there are two points:

1. If you are just interested to know whether the task has been completed or not, Use `executorService.submit(worker)` , instead of `executorService.execute(worker)` method.
2. If you also want to get some result back after the task completion, Use `Callable` interface instead of `Runnable`. See below code:

```
public class A {
  public static void main(String args[]){
    ExecutorService executorService = Executors.newFixedThreadPool(5);
    Callable<String> worker = new FileUploadThread("thread");
    Future<String> workerTask = executorService.submit(worker);

    try {
        boolean isDone = workerTask.isDone();
        System.out.println("Task is done: " + isDone);

        //Wait untill task is executing
        String status = workerTask.get();

        System.out.println("Status: " + status);
        isDone = workerTask.isDone();
        System.out.println("Task is done: " + isDone);
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
    executorService.shutdown();
  }
}

class FileUploadThread implements Callable<String> {
  //has a parametrized constuctor
  public FileUploadThread(String thread) { }

  @Override
  public String call() throws Exception {
    for(int i=0; i<5; i++){
        System.out.println("executing..sleep for 1 sec...");
        Thread.sleep(1000);
    }
    return "DONE";
  }
}

```

**Output:** 

```
Task is done: false
executing..sleep for 1 sec...
executing..sleep for 1 sec...
executing..sleep for 1 sec...
executing..sleep for 1 sec...
executing..sleep for 1 sec...
Status: DONE
Task is done: true

```
When you `start` a thread with **yourThread.start()**, the system starts a new thread doing what is inside the `run` method. You can simply print something like this : `System.out.println("FINISHED " + this.getName())` at the end of the `run` method.

**PS** : please make sure you don't place the print above in some loops, it should be the last statement in the `run` method. ( The .execute() method is **almost** the same thing with .start() )