its seems to be a stupid question but I'm trying to create a task in a new thread, and after the task is finished the thread should exit without calling anything to stop it from main. 

Here is an example:

```

public class Main {

    public static void main(String[] args) {
    // write your code here
        foo f1= new foo();
        Thread t= new Thread(f1);
        f1.doSomething();
    }
}
class foo extends Thread{

    void doSomething(){
        // download File for example
    }
} 

```

if I implement the run method like this :

```
class foo extends Thread{

    void doSomething(){
        // download File for example
    }
    void run(){
      doSomething();
    }
} 

```

it is going to call doSomething() method forever.