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

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ม.ค. 2025

ความคิดเห็น • 8

  • @musondaben7052
    @musondaben7052 2 ปีที่แล้ว +1

    Thank you so much for the video,
    I have understood the differences between runnable and the use of threads....

  • @eridanaeon
    @eridanaeon 2 ปีที่แล้ว +1

    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

  • @freeSpiritNonna
    @freeSpiritNonna 9 หลายเดือนก่อน

    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.

  • @KaulagiSagar
    @KaulagiSagar ปีที่แล้ว +1

    Thank you so much....

  • @blabberq
    @blabberq 2 ปีที่แล้ว +1

    Interesting, I didn't know it 🤔

  • @rajeshcr9800
    @rajeshcr9800 ปีที่แล้ว

    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

  • @AbhishekSrivastavapune
    @AbhishekSrivastavapune 3 ปีที่แล้ว +1

    Very precise and lucid explanation

    • @TechStack9
      @TechStack9  3 ปีที่แล้ว +1

      Thank you Abhishek !!