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”;

}

}

Related topics

Please follow and like us:
Posted in Java   

Core Java Tutorial



Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki