Quantcast
Viewing latest article 45
Browse Latest Browse All 45

Answer by Yogesh Sharma for "implements Runnable" vs "extends Thread" in Java

If you want to separate your concerns like, if you want to create Tasks and it does not matter to you who is the worker working on your task then use Runnable and define your work as a task. Just like when you use executor service, you define tasks in form of Runnable/callable and give them to executor service which will then hold the responsibility of workers.

If you want to create a worker by yourself and assign that worker your task, you want more control over the worker thread then use Thread class.


Viewing latest article 45
Browse Latest Browse All 45

Trending Articles