0
What are different ways to implement thread other than "Thread" class and "Runnable" interface in java?
Give example of thread implementation using all possible ways and give difference as well ass pros and cons of each mechanism. Thanks
2 Réponses
+ 10
Idk any other way, Thread or Runnable do the job.
Thread can be extended, Runnable is an interface and can be implemented. So Runnable has the advantage that you can extend another class if you need to.
Examples:
https://docs.oracle.com/javase/tutorial/essential/concurrency/runthread.html
+ 1
Thanks for explaination.. FYI I came across something called Callable interface introduced in jdk 1.5 through which we can implement thread.. we can overload call() method which is similar to run () method of Thread class and Runnable interface...