Thread vs Runnable vs Callable
40 min · Intermediate
A thread is a separate path of execution inside one Java program, with its own call stack but the same heap as the other threads. The first concurrency questions in almost every interview are how to create one, why start() and not run(), and what states a thread goes through. Section 10, Thread Basics, taught these; this lesson is the revision.
Topics in this lesson
- Three ways to create a thread: Thread, Runnable, Callable
- start() vs run()
- Thread states; sleep vs wait; join
- Callable and Future: return values and exceptions
- Process vs thread; daemon threads
Interview questions this lesson answers
- What is a thread?
- What is multithreading, and why use it?
- What is the difference between a process and a thread?
- How many ways can you create a thread in Java?
- Which is better: extending Thread or implementing Runnable?
- What is the difference between Runnable and Callable?
- What is the difference between start() and run()?
- Can you call start() twice on the same thread?
- What happens if you override start() in a Thread subclass?
- What are the states of a thread in Java?
Sign in free to continue this lesson
Create a free account to read every lesson, practise with the exercises and keep track of your progress.