1

Possible Duplicate:
Implementing Runnable vs. extending Thread

I am very much confused about the perfect answer in simple language for above question. In which scenario which is better and why. can anyone explain.

0

2 Answers 2

2

The Executor classes talk in terms of Runnable, and for that reason alone I favour implementing the Runnable interface. You don't carry the baggage of having your code implicitly tied into a thread and frameworks can handle Runnables in whatever way they prefer.

Sign up to request clarification or add additional context in comments.

Comments

1

Use these simple rules:

1) If the main purpose of a class is to be a thread, then subclass Thread

2) If the main purpose of a class is not to be a thread (e.g.: a GUI component), implement Runnable

3) Use Runnable when the thread class is already sub-classed by another class

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.