Q: Explain different ways of creating a thread. Which one would you prefer and why ?
- Show Answer
- Workspace
- Discuss
Answer :
Explanation :
There are three ways that can be used in order for a Thread to be created: A class may extend the Thread class. A class may implement the Runnable interface. An application can use the Executor framework, in order to create a thread pool. The Runnable interface is preferred, as it does not require an object to inherit the Thread class. In case your application design requires multiple inheritance, only interfaces can help you. Also, the thread pool is very efficient and can be implemented and used very easily.
Similar Questions
Since Nithya and Suganya exchange places, so Rita’s new position is the same as Monika’s earlier position. This position is 17th from the right and 10th from the left. Therefore Number of girls in the row = (16 + 1 + 9) = 26.