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

1st Apr 2017, 8:41 PM
Sbk0103
Sbk0103 - avatar
2 Respostas
+ 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
2nd Apr 2017, 6:01 AM
Tashi N
Tashi N - avatar
+ 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...
2nd Apr 2017, 8:54 AM
Sbk0103
Sbk0103 - avatar