Difference Between Implementing Runnable Interface and Extending Thread Class | Runnable vs Thread

preview_player
Показать описание
This video explains differences between Implementing Runnable Interface and Extending Thread Class

Checkout the Playlists:
👉 Java Tutorial For Beginners:

👉 Design Patterns in Java

👉 Tricky Java Interview Questions

👉 Important Java Programs for Interview:

👉 How to Avoid Common Mistakes as a Java Beginner

👉 Interview Coding Challenges

👉 MySQL Tutorial For Beginners:

👉 What is Agile | Understanding Agile Software Development Process:

👉 Selenium with Java Tutorial For Beginners:

LIKE | SHARE | SUBSCRIBE 😊


👇👇👇
Follow me on
Рекомендации по теме
Комментарии
Автор

Thank you so much for the video,

I have understood the differences between runnable and the use of threads....

musondaben
Автор

I used Runnable interface. I still have my code, back when I was working with jdk.1.4. Main reason I used Runnable is to avoid calling thread's stop() method, which is not advisable back then

eridanaeon
Автор

I think the above results are based on your Runnable-instance threads implementation. For example, if you create:
ImplementsRunnable r1 = new ImplementsRunnable();
Thread t1 = new Thread(r1);
t1.start();

ImplementsRunnable r2 = new ImplementsRunnable();
Thread t2 = new Thread(r2);
t2.start();

ImplementsRunnable r3 = new ImplementsRunnable();
Thread t3 = new Thread(r3);
t3.start();
instead of "Thread t1 = = Thread t2 = Thread t3 = new Thread(r)", all created from the same Runnable instance, the results from both will be the same counter = 1/1/1.

freeSpiritNonna
Автор

hi,

if we miss Thread.sleep(1000) method .. Runnable interface counter showing all count as same.. 3 times counter called.. all will be 3.
not like 1, 2, 3. why it's shwoing if miss sleep() why same value printing.

Thanks
Rajesh

rajeshcr