CodesJava

Easy learning with example program codes

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 “codesjava.com”;

}

}

Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status