13.3 Multithreading using Runnable Interface

Поделиться
HTML-код
  • Опубликовано: 15 ноя 2024

Комментарии • 71

  • @sumrjd
    @sumrjd 5 лет назад +32

    prefect he is really smart talking and not make you feel sleepy he knows how to deal with record voice

  • @vijayvantela
    @vijayvantela 5 лет назад +6

    Hi Naveen Reddy garu,
    Please make a video on complete collections.
    U have so much knowledge in java and superb explanation.Every one will understand your videos.

  • @kahanx10
    @kahanx10 3 года назад

    I'm watching this after 5 years and it still helped me a lot!

  • @patteboyinadharani1702
    @patteboyinadharani1702 3 года назад

    No words to describe about your teaching sir......... 👏👏👏👏👏👏👏

  • @cael_86
    @cael_86 7 лет назад +4

    the way of teaching is really understandable in all the videos.... thank you so much. and the beginning music also nice !!!

  • @bellewolde
    @bellewolde 5 лет назад +8

    Thank you, Sir!!!
    This helps a lot for me.

  • @avinashmodi5230
    @avinashmodi5230 2 года назад

    4:04 Hi Hello was sounding like "Hi Hiku Hi Hiku, hi hi..." , btw your teaching is the best.

  • @abufaya4155
    @abufaya4155 5 лет назад +1

    wow u hav clarity!!n i love people who hav clarity in their ideas!!!!!!

  • @sengottaiyanperiyasamy5459
    @sengottaiyanperiyasamy5459 3 года назад +3

    Hi, how can we implement thread in spring projects , please provide the exact real time scenario. Thanks

  • @manandesai6404
    @manandesai6404 5 лет назад

    Very easy to understand java when you teach us sir .....

  • @TheFlyguy31
    @TheFlyguy31 7 лет назад

    Brilliant as usual, Mr Reddy...

  • @Sudarshan-Advocate-Labrador
    @Sudarshan-Advocate-Labrador 7 лет назад +1

    Excellent Videos offered by you . keep going on

  • @bharadwaj25
    @bharadwaj25 7 лет назад +6

    Excellent again

  • @muhammadbilalmalik7292
    @muhammadbilalmalik7292 4 года назад

    Perfect Telusko Binod!!!!

  • @rotorfpv4117
    @rotorfpv4117 8 лет назад +2

    Hello from Poland !

  • @shyamkachhadiya4964
    @shyamkachhadiya4964 6 лет назад +2

    Ah sir can we have some more videos on Runnable and multithreading please :)

  • @srimanyadagiri7831
    @srimanyadagiri7831 5 лет назад

    Excellent Video, But technically it is not an object of Runnable but reference of the interface Runnable.@4.35

  • @RohithInnamuri
    @RohithInnamuri 8 месяцев назад

    Excellent video

  • @sreenivask7072
    @sreenivask7072 6 лет назад

    Great job sir u r videos are very helpful

  • @abdulashique
    @abdulashique 4 года назад

    It will also work the same, even if you create objects of the Class itself and not Runnable interface
    FirstThread firstThread = new FirstThread();
    SecondThread secondThread = new SecondThread();
    Thread t1 = new Thread(firstThread);
    Thread t2 = new Thread(secondThread);
    t1.start();
    Thread.sleep(10);
    t2.start();

  • @VinothiniAnabayan
    @VinothiniAnabayan 3 года назад

    Please make a video on completable future

  • @SuperAussi3
    @SuperAussi3 5 лет назад

    I highly admire you, from tanzania

  • @gladyouseen8160
    @gladyouseen8160 5 лет назад

    Why we are using the reference of runnable? Can we use interfaces to refer objects? Why? Please tell me 3:42

  • @nakulvs9694
    @nakulvs9694 5 лет назад

    i have a doubt.What is the difference between "different threads with different instance of the class and different threads with the same instance of the class" ?

  • @ValatY
    @ValatY 5 лет назад

    Wow that's really well explained! Thanks man

  • @ImCookedByCodes
    @ImCookedByCodes 2 месяца назад

    Thankyou sir ❤

  • @bouhenniouahiba8892
    @bouhenniouahiba8892 4 года назад

    hello,
    how I do the synchronization with algorithm between multiple clients

  • @raghavenderraosaini6624
    @raghavenderraosaini6624 6 лет назад

    what is the difference between an abstract class and an interface if have two methods in getting a thread

  • @mananchawla9324
    @mananchawla9324 3 года назад

    how is runnable interface linked to Thread class ?

  • @chimdesaasebe4511
    @chimdesaasebe4511 6 лет назад

    nice concept sir.Thank you

  • @wshacode7179
    @wshacode7179 2 года назад

    so help full really

  • @simplelife8722
    @simplelife8722 7 лет назад +1

    Sir, why cant we simply write
    obj1.run();
    instead of,
    Thread t1 = new Thread(obj1);
    t1.show();

    • @sanjaymanna9278
      @sanjaymanna9278 7 лет назад +1

      we can ,but it treats like a normal method actually when we call start() method,its look like this
      public void start(){
      run();
      //some other code
      }
      and more over if don't use start method we cant achieve multithreading

    • @jatinlalwani9459
      @jatinlalwani9459 7 лет назад

      If you write obj1.run() it will run normally but here you want it to run like a thread (because we are learning multithreading). If you want it to run like a thread you need methods from Thread class.

  • @ArunraajSingh
    @ArunraajSingh 7 лет назад

    Hi sir,
    Why there are two ways to achieve multithreading?
    What is the difference between using Runnable and Thread?

    • @Prabhatsasaram
      @Prabhatsasaram 6 лет назад

      Runnable is an interface but Thread is a class. so once you extend the Thread you can't extend any other class. but when you implement Runnable you can chance to extend the class if any.

  • @MuhammadAmir-mf9xt
    @MuhammadAmir-mf9xt 8 лет назад

    thnaku sir amazing explanation

  • @vibhorsteele
    @vibhorsteele 4 года назад

    @Telusko Hi! How did you go to the declaration of the interface runnable at 0:47? Which shortcut did you use? Kindly tell me how to see the documentation using that keyboard shortcut?

    • @pragyasingh3018
      @pragyasingh3018 4 года назад +2

      press ctrl+LMB(left mouse button or a simple click lol) while pointing the cursor on the keyword.

  • @vishalmishra1937
    @vishalmishra1937 7 лет назад

    sir in this program switching will take place or not??

  • @harshagangari2150
    @harshagangari2150 5 лет назад +1

    Even though i have entered the same code my output is five time hi folled by five times hello. Any help?

    • @AshishKumar-wl6od
      @AshishKumar-wl6od 4 года назад +1

      Sometimes it depends on your system processor also, don't think every system will gives u the same output

  • @animeshchakraborty9908
    @animeshchakraborty9908 6 лет назад

    Nice video sir

  • @anmoljain5995
    @anmoljain5995 5 лет назад

    There is one thread in each program execution that is main.
    So while we are executing the main thread it is a single thread and executes each command line by line.
    But here when we are writing t1.start() and then it t2.start() then it should execute the t1.start() command completely and then only go to the next line.
    Could you please explain this?

    • @abinasha543
      @abinasha543 2 года назад

      t1 is a thread so it works on its own, main thread simples moves on after invoking thread t1. t1 thread's process is taken care by t1 thread not main thread.

  • @alkawra
    @alkawra 8 лет назад +1

    hello , i cant see imported packages in that file you are coding in ?

    • @ArunraajSingh
      @ArunraajSingh 7 лет назад +1

      Runnable, Thread come under java.lang package and this is imported in java by default.

  • @ronnypro3041
    @ronnypro3041 4 года назад

    thanks.. so helpful

  • @rajshreegavel5966
    @rajshreegavel5966 5 лет назад

    I have a query, we cannot make object of an interface then why is it written -> 'Runnable' obj1 = new Hi(); or 'Runnable' obj2 = new Hello();

    • @alimd7648
      @alimd7648 4 года назад

      we are not creating object of interface
      Actually we are creating object of class 'Hi' and 'Hello'
      new keyword is used to create object and observe that it used for classes

  • @hassaanahmad5152
    @hassaanahmad5152 5 лет назад

    Sir you have made me conquer java in no time.....for(int x=1;x

    • @billysmith3399
      @billysmith3399 4 года назад +1

      you can't be equal to infinity, get wreckt liberal

    • @hassaanahmad5152
      @hassaanahmad5152 4 года назад +1

      @@billysmith3399 it was just a figure of speech you dumb duck

  • @decodingmyroot
    @decodingmyroot 2 года назад

    Thanks

  • @aadilkp5335
    @aadilkp5335 5 лет назад

    Sir when I'm running this code I'm getting 10 hi and hello each...Why?

    • @kashif2309
      @kashif2309 5 лет назад

      he explained this in the previous video.

  • @yt.user-zull
    @yt.user-zull 6 лет назад

    Very nice! 👍

  • @subasreesuriyakumar3442
    @subasreesuriyakumar3442 7 лет назад

    Thank you....

  • @anikeatbansal6916
    @anikeatbansal6916 7 лет назад

    why we used runnable in the following statements :-
    Runnable obj1 = new Hi();
    Runnable obj1 = new Hello();
    And also why we are not writing obj1 and obj2 in t1.start() and t2.start() resp ?

    • @lgiorgos1
      @lgiorgos1 4 года назад

      I wrote Hi obj1 = new Hi(); and there was no difference.

  • @dodsa247
    @dodsa247 2 года назад

    Can anyone explain this code to me please!!!
    class myThread implements Runnable{
    Thread t;
    myThread(){
    //creates a my thread
    t = new Thread(this , "Demo thread");
    System.out.println("child thread : " +t);
    }
    //this is the entry point for 2nd thread
    public void run(){
    try{
    for(int i=5 ;i>0 ; i--){
    System.out.println("child thread : " +i);
    Thread.sleep(500);
    }
    }catch(InterruptedException e){
    System.out.println("child interrupted ");
    }
    System.out.println("exiting child thread ");
    }
    }
    class ThreadDemo{
    public static void main(String args[]){
    myThread nt= new myThread();
    nt.t.start();
    try{
    for(int i=5 ;i>0 ; i--){
    System.out.println("MAIN thread : " +i);
    Thread.sleep(1000);
    }
    }catch(InterruptedException e){
    System.out.println("main thread interrupted ");
    }
    System.out.println("exiting main thread ");
    }
    }

  • @sanjaymanna9278
    @sanjaymanna9278 7 лет назад

    if u write few lines of code after calling the start method,why those codes execute first???
    t1.start();
    try{Thread.sleep(10);}catch(InterruptedException e){System.out.println(e);}
    t2.start();
    System.out.println("happy codding");
    and it gives output like this
    happy codding
    Thread 1
    Thread 2
    Thread 1
    Thread 2

    • @Prabhatsasaram
      @Prabhatsasaram 6 лет назад

      If you want to print "happy codding" in the end then you can use the join method.

  • @akashshrestha8932
    @akashshrestha8932 5 лет назад

    cool

  • @N63B44TÜ
    @N63B44TÜ 5 лет назад

    you are explaining very well, thx. I would say your videos are so good like the ones by thenewboston except you dont objectify your exs LOL

  • @yashtibrewal4259
    @yashtibrewal4259 6 лет назад

    my.concept++;

  • @lukescurrenthobby4179
    @lukescurrenthobby4179 4 года назад

    I guess I'm gonna have to get used to this indian slur english if i'm gonna use youtube for java help

  • @darshangaikwad8626
    @darshangaikwad8626 4 года назад

    when i use start method it shows error but when i use run in it shows coorect ouput please answer me why this occurs

    • @darshangaikwad8626
      @darshangaikwad8626 4 года назад

      sorry when i call start method it shows error but when i call run it runs correctly

    • @adityamishra2044
      @adityamishra2044 4 года назад

      It's maybe bug just creat a new class and write again and now bingo u won't get output it will tell exception by the way same thing happened with me🤣