Комментарии:
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 ");
}
}
so help full really
ОтветитьThanks
ОтветитьI'm watching this after 5 years and it still helped me a lot!
ОтветитьPlease make a video on completable future
Ответитьhow is runnable interface linked to Thread class ?
ОтветитьNo words to describe about your teaching sir......... 👏👏👏👏👏👏👏
ОтветитьHi, how can we implement thread in spring projects , please provide the exact real time scenario. Thanks
Ответитьwhen i use start method it shows error but when i use run in it shows coorect ouput please answer me why this occurs
ОтветитьPerfect Telusko Binod!!!!
Ответитьhello,
how I do the synchronization with algorithm between multiple clients
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();
thanks.. so helpful
ОтветитьVery easy to understand java when you teach us sir .....
ОтветитьSir you have made me conquer java in no time.....for(int x=1;x<=infinity;x++){System.out.println"Respect and Love"}
Ответить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
Ответить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.