difference between callable and runnable

                          Runnable                            Callable
Available in java.lang package.Available in java.util.concurrent package.
Method: void run()Method: V call() throws Exception
It cannot return any value.It can return value.
It cannot throw checked exception.It can throw checked exception.
class TestThread implements Runnable {

@override

public void run(){

//do something

}

}

class TestThread implements Callable<String> {

@override

public String call() throws Exception {

//do something

return “w3spoint.com”;

}

}

Content Protection by DMCA.com
Please Share