Tap to unmute

Core Java with OCJP/SCJP: Multi Threading Part-11 || Inter Thread Communication Part-2

  Рет қаралды 241,863

Durga Software Solutions

Durga Software Solutions

Күн бұрын

Пікірлер: 172
@dreamersharma3743
@dreamersharma3743 8 жыл бұрын
Durga Sir Hats Off to you. I don't know how to thanks because nobody teach this for free, So blessings from my side. Keep Working and looking forward for more tutorials to get update. Thanks.
@abarag8
@abarag8 7 жыл бұрын
Dreamer sharma I
@sankalparora9374
@sankalparora9374 2 жыл бұрын
The way this guy teaches is the best: the time he puts on every topic, the clear notes that he gives, the flow of delivery of the lectures, without any kind of distractions like PPT and all. We get to listen the thought process of a real Java Developer whenever we listen to any of his videos. Truly amazing. There could be no one like Durga Sir.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 2 жыл бұрын
Hello Sankalp. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
@gwalaniarun
@gwalaniarun 6 жыл бұрын
I watched telusko videos because of duration time but your quality of teaching worth this time. Thanks.
@venkatasudheerkavuru5666
@venkatasudheerkavuru5666 4 жыл бұрын
Bro which one is better
@yoshitamahajan353
@yoshitamahajan353 4 жыл бұрын
@@venkatasudheerkavuru5666 I thik durga soft videos are way better to understand the concept..
@sudhanshuprakash2313
@sudhanshuprakash2313 4 жыл бұрын
Durga sir is the best teacher I have seen in my entire life.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 4 жыл бұрын
Hello Prakash. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
@vincentmax4571
@vincentmax4571 6 жыл бұрын
You are one of the greatest living human. Respect for your passion for teaching and that style. Love you sir.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 6 жыл бұрын
Hello Vincent Max. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
@skarre87
@skarre87 4 жыл бұрын
Durga sir is best at doing postmortem...Love to watch ur tutorials...Mind blowing work sir....Thanks for all this content you provide.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 4 жыл бұрын
Hello Sushant. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
@mrProgrammingGeek
@mrProgrammingGeek 4 жыл бұрын
At 34:20, if the child thread got the lock first before the main thread, then the notification will be sent and the main thread will always keep waiting. This example at 34:20 is okay to drive the point of wait and notify but wait MUST always happen before notify between inter-thread communication OR wait should be for a specific time interval
@Coders_World
@Coders_World 7 ай бұрын
I had same doubt. Thanks for Clarifying.
@sakshiaggarwal3838
@sakshiaggarwal3838 6 жыл бұрын
Durga Sir ! You are "THE BEST"
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 6 жыл бұрын
Hello Sakshi Aggarwal. Thanks for your valuable feedback.It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/U1KKyi You an see more Java videos following link: Java tutorial by durga sir goo.gl/XWb4RL Java 9 by durga sir goo.gl/hXGyBW Java 1.8 Version New Features by Durga sir goo.gl/iHXXYU Adv Java JDBC Tutorial by Durga sir goo.gl/8q16Eo OCJA 1.8 Java SE 8 Programmer - I (1Z0 - 808 ) By Durga sir goo.gl/gC6R7f Core Java by NagoorBabu sir goo.gl/s6Nvj1 Advenced Java by Nagoorbabu sir goo.gl/ZZonzJ CoreJava by Ratan goo.gl/3VM19v Advanced Java jdbc by Ratan goo.gl/Rn2UXr Advjava tutorials - JSP by Ratan goo.gl/Z6ytxm Adv java servlets tutorial by ratan goo.gl/zTwi9y Servlet and JSP Tutorial by anji reddy goo.gl/jZMRUv Advanced Java Jdbc by Anjireddy goo.gl/16CGzX Hibernate byAnjireddy goo.gl/qQojvZ Struts by Anjireddy goo.gl/nE1Eof Spring by Mr.AnjiReddy goo.gl/NfN14R ADV JAVA by Naveen goo.gl/bhSsXF Spring by Mr.Naveen goo.gl/huVwFN Hibernate by Mr. Naveen goo.gl/TY3Wpd Struts by Mr.Naveen goo.gl/Vkmiw7
@tharunkumar27
@tharunkumar27 4 ай бұрын
I have never seen James Goslin but i saw Durga sir. What an explanation and knowledge sir. Hats off to you and thank you from the bottom of my heart.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 4 ай бұрын
Hello Tharun. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
@eadunuripranay5977
@eadunuripranay5977 4 жыл бұрын
OMG the real talent guy @DURGA sir......i don't know how ur simplifying the concepts and from where the entire content u have grabbed and giving lecture, so i could better conclude saying this will be the best comment sir for u i.e, durga java content=google entire java search.......if u feel like telling can u please let us know how the depth content of learning u have planned and standing currently...so that we can also followur footsteps....so hoping please comment answer for my question sir which will be helpful for all the ones who views this comment.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 4 жыл бұрын
Hello Pranay. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@debaduttapanda9173
@debaduttapanda9173 6 жыл бұрын
Thanks a lot sir...coz of u like we people from non branch also can understand the complete terminology......... U R simply BEST
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 6 жыл бұрын
Hello Panda. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
@niloymridha1717
@niloymridha1717 4 жыл бұрын
I am from bangladesh. i am very happy to write something about durga sir. He not only a good teacher but also a good mentality perosn. i just make my pasport to meet with durga sir in hydrabad.I don't know when i will go but i know i must meet with my best java teacher at any cost. I am coming father of java.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 4 жыл бұрын
Hello Niloy. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
@niloymridha1717
@niloymridha1717 4 жыл бұрын
@@DurgaSoftwareSolutionsCan you tell me how can i meet with durga sir please?
@mayurthetraveller
@mayurthetraveller 8 жыл бұрын
Durga Sir Hats Off to you. I don't know how to thanks because nobody teach this for free, So blessings from my side. Thanks. yo soooooooo much, i will definitely come to meet you :)
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 8 жыл бұрын
Thank u Mayur... Plz keep watching our videos on You Tube.
@kumarvelu
@kumarvelu 5 жыл бұрын
Durga sir giving left and right to threads.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 5 жыл бұрын
Hello Kumar Velu. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
@akashkala9299
@akashkala9299 3 жыл бұрын
haha Epic :)
@amolsathewad7594
@amolsathewad7594 8 жыл бұрын
Hats off to Durga sir....Thanx for providing quality teaching
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 8 жыл бұрын
Hi Amol.. thank your for you feedback
@pushparay5554
@pushparay5554 7 жыл бұрын
Sir huge respect to you. The best teacher you are!!!!!!
@utkarshsalaria3952
@utkarshsalaria3952 3 жыл бұрын
Sir your explanation is great!! NO ONE TEACHES THAT WELL..✌👍
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 3 жыл бұрын
Hello Utkarsh. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
@hi10drakk
@hi10drakk 3 жыл бұрын
Please add keywords - wait, notify, notifyall, producer consumer by durga sir himself - the Java god
@m.smanoj4688
@m.smanoj4688 Жыл бұрын
in multithreading this is one of the difficult concept with durga sir therse no word for difficulty😁😁😁😁😁😁
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions Жыл бұрын
Hello Manoj. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
@prakherjindal5440
@prakherjindal5440 Жыл бұрын
comparing sleep(), join(), wait() - 17:00 - 21:55
@divyadixit4698
@divyadixit4698 6 жыл бұрын
thanks alot sir ji nobody teaching like you you are man kind angel
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 6 жыл бұрын
Hello Divya. Thanks for your valuable feedback.It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
@divyadixit4698
@divyadixit4698 6 жыл бұрын
thanks sir my pleasure
@coolprashantmailbox
@coolprashantmailbox 8 жыл бұрын
awesome video..thank u for uploading by Durgasoft
@DeepakKumar-dw1re
@DeepakKumar-dw1re 2 жыл бұрын
Mst Durga sir😎
@abhijitchikane
@abhijitchikane 5 жыл бұрын
Sir when b thread get 1st chance to execute it will call notify method which will be waste and the main will going in the waiting state then what u do is just pass the time parameter of 10 second 46:54 in this case also the performance will reduce as the main is waiting for the no reason and the sleep() method is doing the same work instead of wait() ? Can you explain little bit about it?
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 5 жыл бұрын
Hello Abhijit. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@anupamawasthi12
@anupamawasthi12 5 жыл бұрын
Agree! if we do something like this in main method syncronized(b) { b.start(); b.wait(); print(b.total) } this will make sure that main thread always gets the lock first and child thread cannot enter the synchronized area inside run() method, so b.wait() will execute first and then only child thread will enter its synchronized area. this solves the problem.
@mohanrajs9917
@mohanrajs9917 4 жыл бұрын
Thank you so much sir, this session is very understandable.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 4 жыл бұрын
Hello Mohanraj. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
@rizwanshahid1447
@rizwanshahid1447 7 жыл бұрын
Thanks so much, Durga Sir.
@manassahoo2750
@manassahoo2750 2 жыл бұрын
Thank you very much sir ❤️
@thinksix1925
@thinksix1925 4 жыл бұрын
Thanks for teaching sir 🙏
@fathimafathima1681
@fathimafathima1681 2 жыл бұрын
1:04 - difference between notify and notifyAll
@somubolla2161
@somubolla2161 8 жыл бұрын
Please upload Core Java with OCJP/SCJP: Multi Threading Part-11 || Inter Thread Communication Part-1 don't forget to upload Part 1
@ranveervaghela7030
@ranveervaghela7030 5 ай бұрын
Completed watching on 06-08-2024 at 5.45 pm
@rakhigandhi6802
@rakhigandhi6802 5 жыл бұрын
Great video!
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 5 жыл бұрын
Hello Rakhi. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
@prabhudeepsingh4236
@prabhudeepsingh4236 7 жыл бұрын
To get all the programs of Multi Threading give a star to the following repository: github.com/PrabhudeepSingh/Java-07-MultiThreading Follow github.com/PrabhudeepSingh for more such code.
@m.smanoj4688
@m.smanoj4688 Жыл бұрын
thought first part of inter thread communucations feels lengthy with second part we can understand inter thread communication concept beautifully. As always java means durga durga means java no doubt at all
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions Жыл бұрын
Hello Manoj. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
@knowledgeshare1622
@knowledgeshare1622 Жыл бұрын
Hello Durga Sir, 25:01 why we make synchronized(b) ?? Can't we make synchronized(this)??
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions Жыл бұрын
Hello Friend. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@its_rk2448
@its_rk2448 Жыл бұрын
To particularly mentioning a object we have to write it.. If it is the one object then u can use this
@sug_madic7683
@sug_madic7683 4 жыл бұрын
52:24 this is the reason you came for
@sug_madic7683
@sug_madic7683 3 жыл бұрын
I cant believe that i got an heart I was just chilling in my holidays to learn something new
@akshaybhoi8092
@akshaybhoi8092 3 жыл бұрын
Dear durga Sir , please make some videos on REFLECTION API. do postmottom on that topic. please sir....
@malharjajoo7393
@malharjajoo7393 7 жыл бұрын
The example at 27:00. what do you mean when you say that the main thread acquires the lock of the "b" object , How can the main thread acquire the lock of a thread "b" , and the thread itself ( "b" herre ) does nt have it's own lock ?
@ShahzebAhamd-x3p
@ShahzebAhamd-x3p 11 ай бұрын
We can call join method too to get the correct output
@vivekbudge9706
@vivekbudge9706 4 жыл бұрын
Thank you so much sir
@rupeshgaming1604
@rupeshgaming1604 Жыл бұрын
Jay Jagannath 💜
@benzo_uncle
@benzo_uncle 6 жыл бұрын
21:00 Sir u said that thread can wait for getting the lock but now at that point u said that that thread dont wait and after this.notify() other thread will just print total!!
@programmer6649
@programmer6649 3 жыл бұрын
Paina kinda voopu durga sir java lo thopu 😂😂
@EngineerVaibhav
@EngineerVaibhav Жыл бұрын
91th video🎥🎉❤
@utkarshsalaria3952
@utkarshsalaria3952 3 жыл бұрын
sir please provide one example of notifyAll() method
@sheelstera
@sheelstera 6 жыл бұрын
in the producer-consumer problem, the wait() method should not be inside the if-else block otherwise after the producer notifies the consumer thread and wakes the consumer thread to continue processing, the consumer thread will skip processing and consuming the items from the queue as that logic resides in the else block and which therefore is never going to be reached as the wait() is in the if block and the next instruction that the consumer thread will execute will be after the if-else block..the correct sequence should be: if (q is empty) { q.wait(); consumeItems ... .. . }
@saurabhdsawant
@saurabhdsawant 5 жыл бұрын
Queue is FIFO so if queue has anything produced we can consume , but need to do wait only when we do not have anything to consume .
@sheelstera
@sheelstera 5 жыл бұрын
@@saurabhdsawant Not always true..the thread goes into wait() when queue is empty.. and what happens when producer puts the items in the queue and notifies()???---> the consumer starts to execute when it gets the chance...and what does it do as the first thing???---> immediately execute the next instruction after wait() which is jump out of the if-else block...and where is the queue processing logic???---> in the else block...so you are skipping that part..unless you put this entire thing in a loop which you will... but still be wasting a couple of CPU cycles..
@adhwareshpandey2635
@adhwareshpandey2635 8 жыл бұрын
Sir first of thanx for the video, I want to ask something, at 48:00 what if we call sleep() method from child object synchronized block.
@mayurthetraveller
@mayurthetraveller 8 жыл бұрын
thank you so much for being here for...
@rajyasriashok1154
@rajyasriashok1154 6 жыл бұрын
1:02:10 in producer-consumer problem, the consumer has acquired the lock on q object and waiting(q.wait()), then how the producer can call q.notify() method because it has to get lock of q object for doing so. But lock is with consumer. Please clarify.
@its_shubh
@its_shubh 6 жыл бұрын
The wait() method will immediately releases the lock of the object.
@ratimohan5765
@ratimohan5765 6 жыл бұрын
Sir you said runnable interface is recommended to implement in multi threading , then why are you giving example with extending Thread class. Is there any reason behind this??
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 6 жыл бұрын
Hello Mohan. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627,7207212427/28
@राजनगोंगल
@राजनगोंगल Жыл бұрын
👍👍👍👍👍👍
@TheSarthak425
@TheSarthak425 6 жыл бұрын
Thank you sir!
@saurabhgupta2057
@saurabhgupta2057 7 жыл бұрын
please explain volatile.. coz it is very important for interview
@pranapsahoo7980
@pranapsahoo7980 7 жыл бұрын
Hi Durga Sir, I am a big fan of yours..Please give an example wait without notify().When i try this first i thought thread calling wait will remain in waiting state forever.However the code executes fine . Please find below code. package com.test.ThreadDemo; public class ThreadExecutor { public static void main(String[] args) { ChildThread childThread = new ChildThread(); childThread.start(); synchronized (childThread) { try { childThread.wait(); System.out.println("Waiting ends"); } catch (InterruptedException e) { e.printStackTrace(); } } System.out.println("This is Main Thread"); } } class ChildThread extends Thread{ @Override public void run() { for(int i=0;i Value : 0 Value : 1 Value : 2 Value : 3 Value : 4 Value : 5 Value : 6 Value : 7 Value : 8 Value : 9 Waiting ends This is Main Thread i thought main thread will remain in waiting state forever.Please help me in getting the reason behind this.
@deepakpatre4874
@deepakpatre4874 5 жыл бұрын
Dear Sir, To get entered into synchronized block, is there any restriction to have a lock of that particular object(synchronized block declared as to get lock of a perticular object).
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 5 жыл бұрын
Hello Deepak. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@pavithrasenthil7093
@pavithrasenthil7093 4 жыл бұрын
sir,why synchronization in both child and parent class compulsory required
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 4 жыл бұрын
Hello Pavithra. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@christopherami8142
@christopherami8142 4 жыл бұрын
because in both threads, the lock key is required in a sequential way. Since the main thread should wait for child thread to get updated information then therefore main thread should first be owner of the child object that is main thread should has child lock key and lock key is applied in synchronized area...on the other hand when main thread is waiting, the child thread is executing if and only if having the lock key and thus need to be also in synchronized area and since child is calling the notify method, this can only be done in synchronized area...
@pavithrasenthil7093
@pavithrasenthil7093 4 жыл бұрын
@@christopherami8142 thank you 👍
@prathi1212
@prathi1212 5 жыл бұрын
wait() is not a native method right? Why is the console showing java.lang.Object.wait(native method) ? At 23:34
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 5 жыл бұрын
Hello Prathibha. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@somubolla2161
@somubolla2161 8 жыл бұрын
Need to upload Inter Thread Communication Part- 1 please
@renjithr7676
@renjithr7676 5 жыл бұрын
In the first wait and notify example, The execution flow was main thread got chance for execution then child thread got chance for execution. Can it be reversed, sir told that most of the time main thread will get chance. Is there a strict rule saying thread calling wait method has to run first then thread calling notify method?
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 5 жыл бұрын
Hello Renjith. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@shankars4281
@shankars4281 4 жыл бұрын
Same doubt for me, what if child thread gets executed first and gets the lock of object b ?
@vasireddyganesh
@vasireddyganesh 4 жыл бұрын
@@shankars4281 same doubt...bro...Can u plz clear my doubt ...if ur doubt got clarified...
@sripolisettys
@sripolisettys 3 жыл бұрын
@@vasireddyganesh watch 37:00
@AJAYKUMAR-lp6sv
@AJAYKUMAR-lp6sv Жыл бұрын
Does it get resolved or not buddy ..I have the same issue
@vishalgadapa7869
@vishalgadapa7869 4 жыл бұрын
Sir, I commented the call to notify method, the program doesn't actually wait it completes the execution which is not expected. If I include the sleep method then the main thread waits and the child thread executes first after which the main thread waits forever as expected.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 4 жыл бұрын
Hello Vishal. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@nithinreddy1242
@nithinreddy1242 2 жыл бұрын
I wonder how join() method is able to call wait(0) internally from non-synchronized are😮
@amolsathewad7594
@amolsathewad7594 8 жыл бұрын
sir ...please upload All Swing video by durga sir
@venkatb8317
@venkatb8317 Жыл бұрын
Hi Durga Sir, to call wait and notify method we need synchronized. main method i can make it as synchronized and run() method also but why am getting IllegalMonitorStateException at main() bcoz we need call those methods from synchronized, we are calling same, why am getting error please explain sir //code public class InterThread { public static synchronized void main(String[] args) throws InterruptedException { CountThread ct = new CountThread(); ct.start(); System.out.println("wait method is called...............!"); ct.wait();//(InterThread.java:12) error line System.out.println(ct.i); System.out.println(Thread.currentThread().getName()); } } class CountThread extends Thread { int i; @Override public synchronized void run() { Thread.currentThread().setName("CountThread"); for (int j = 1; j
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions Жыл бұрын
Hello Venkat. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@devashishchoubey1965
@devashishchoubey1965 6 жыл бұрын
thnx sir
@vaibhavpal1
@vaibhavpal1 6 жыл бұрын
Thankyou sir
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 6 жыл бұрын
Hello Vaibhav. Thanks for your valuable feedback. It will boost us to do new things. Please subscribe to get updates about new videos. You can view all other Core Java with SCJP/OCJP Videos by Durga sir in the following link: goo.gl/kqvaf2
@PandeyRavindra1
@PandeyRavindra1 8 жыл бұрын
amazing explanation sir.....
@saritasrivastava4599
@saritasrivastava4599 6 жыл бұрын
when is wait without arguments required ?? You said when there is another thread to notify but thats the same case which you mentioned and it created problem when child thread was called first.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 6 жыл бұрын
Hello Sarita. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@MrSahilkaura
@MrSahilkaura 6 жыл бұрын
Hi, i have one doubt, As you said join will not release the lock, just replace join with wait in synchronized block.. as it will not release lock because of join and thread will go in waiting state.. on other hand there is also another synchronized block of same object , as lock is already held by join, synchronized block should not execute right?? Because other thread will require lock on same object which join is already holding.... so how is this executing.. i already tried many times and is successfully executing but how?????
@bipinsingh1490
@bipinsingh1490 5 ай бұрын
How 10 thread are waiting on one object as lock is required so only one thread should be in the waiting state .. correct me if i am wrong
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 5 ай бұрын
Hello Friend. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@n.rukkumani7297
@n.rukkumani7297 8 жыл бұрын
sir at 47minits in video after b.start(); there is two thread one is main thread and child thread how it possible main thread always has the chance child thread also will have chance na sir .without main thread sleeping statement child thread will have chance na sir
@vishalaggarwal1573
@vishalaggarwal1573 8 жыл бұрын
definitely the child thread may execute first but to show programmatically sir did this..
@n.rukkumani7297
@n.rukkumani7297 8 жыл бұрын
thank u
@johnwickgaming6938
@johnwickgaming6938 5 жыл бұрын
It depends on thread scheduler
@nandamudiravali2382
@nandamudiravali2382 7 жыл бұрын
is there any possibility to run another thread while one thread is in sleep
@ramandeepdhir9795
@ramandeepdhir9795 6 жыл бұрын
Sir , at 17:17 for sleep method u wrote , Thread.sleep(10000); But when u replaced sleep method with join method then u wrote b.join(); Why we can't write Thread.join();
@prakharjha7176
@prakharjha7176 6 жыл бұрын
because for calling join method you need to specify on which thread object you want to call it, otherwise current thread from where you are calling join won't know which thread to join. It is a instance method of Thread class
@y.prakashrao511
@y.prakashrao511 Жыл бұрын
43:40 🤣🤣🤣🤣🤣🤣🤣
@koppulapramod554
@koppulapramod554 6 жыл бұрын
What happen if child thread got the chance instead of main thread??
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 6 жыл бұрын
Hello Pramod. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627,7207212427/28
@Ganeshpatil-ow6ej
@Ganeshpatil-ow6ej 7 жыл бұрын
sir plz solve my problem... in above example inter thread communication((example ThreadA and ThreadB extends thread)first main thread gets the chance execute until b.wait() method and main goes to wait state......suppose if i comment... this.notify...in my ThreadB class......the code below the b.wait() is executing..like synchronized(b) { System.out.println("++++++"); b.wait(); System.out.println("the value of total is "+b.total);.........how this line is executing sir...i already commented the ( this.notify) in my class ThreadB } ...sir u said until notification came main thread will be in wait state )
@icecream-pq5uy
@icecream-pq5uy 7 жыл бұрын
At 44:00 full of hair and so on.. are you main ? hahah!!
@adishjain2507
@adishjain2507 8 жыл бұрын
Thanks for the videos. I had one doubt: When calling sleep() method ( sleep() method doesn't leave the lock) in main thread, assuming that main thread is chosen by the Thread Scheduler first, then why is the output coming 5050 always, I mean how come the control went to the child thread to calculate the total sum. It should have first completed the main thread(even if it is sleeping bcoz sleep doesn't release the lock) and printed the output as 0. Please clarify this point.
@KuldeepSharma-vs6yf
@KuldeepSharma-vs6yf 8 жыл бұрын
HI Durga Sir please clarify this point
@ArunraajSingh
@ArunraajSingh 8 жыл бұрын
Hey bro, it will never print 5050 if Main thread executes first. It will print main-thread statements first with "total=0" then all child-thread statements, that's it.
@mahesh_kok
@mahesh_kok 7 жыл бұрын
If sleep method is outside synchronized block then it never acquired lock so there is no chance of releasing the lock and rest will be same and if sleep is inside synchronized block then it will acquire lock and will go to sleep keeping that lock and meanwhile it is sleeping child thread wont be able to execute it ....below is the program public class ThreadA { public static void main (String[] args) throws InterruptedException { ThreadB b =new ThreadB(); b.start(); synchronized(b) { System.out.println("main thread going for sleep"); Thread.sleep(2000); System.out.println("main thread calling wait method"); b.wait(100); System.out.println("main thread got notified"); System.out.println("main thread printing total : "+ b.total); } } } public class ThreadB extends Thread { int total=0; public void run() { synchronized(this) { System.out.println("child thread starts calculation"); for(int i=1;i
@MrShubhamenx
@MrShubhamenx 7 жыл бұрын
main thread made child thread's state Ready/Runnable before itself going to sleep. So, the current running thread is main in the processor and while running(run()), it goes to sleep and main thread changes its running state to sleeping state. Now, the thread scheduler takes child thread into consideration since main thread is in a sleep state. Therefore, child thread acquires the lock of our mutual single object and enters running state through the run() and finally calculates the sum and the child thread's state becomes dead. In the interim of 10 seconds sleep of main thread, all the above things happened and now after 10 seconds when a main thread wakes up, it goes into the Ready/Runnable state.
@pratikbhardwaj3804
@pratikbhardwaj3804 7 жыл бұрын
only wait notify and notifyall methods can leave the lock , no other methods in java
@sobhan34
@sobhan34 7 жыл бұрын
guys i have a doubt will be glad if u clear. in the above program total variable is declared i threadb class and threada class trying to print the same in its class. is it possible to print a variable with out declaring in its class scope
@kumarsantoshdash
@kumarsantoshdash 7 жыл бұрын
Yes, If it is not declared private or in the same package. Go through variable scope in java. Following link might help. www.geeksforgeeks.org/variable-scope-in-java/
@MrShubhamenx
@MrShubhamenx 7 жыл бұрын
Look carefully. The object of ThreadB that is "b" is declared and initialized in class ThreadA (HAS-A). The scope of reference variable "b" is perfectly valid since synchronized block is also inside the main method. Synchronization block can use main method's local variable.
@deepakbansal900
@deepakbansal900 6 жыл бұрын
I think, u r saying that u want to get the total value without declaring it in class. It would not be possible because run method returns nothing. So we will required an object or primitives to get an updated value.
@rakeshkumarparida98
@rakeshkumarparida98 4 жыл бұрын
Sir I am not getting output as 5050 or any intermediate number, I am getting only zero when I run the code. Sir if you help me out from this situation I would sleep in piece. Please sir My code is below please have a look : - class ThreadA { public static void main(String[] args ) { ThreadB b = new ThreadB(); b.start(); System.out.println(b.total); } } class ThreadB extends Thread { int total = 0; public void run() { for(int i = 0; i
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 4 жыл бұрын
Hello Rakesh. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@ravishekhar1428
@ravishekhar1428 4 жыл бұрын
public class NotifyWait2 { public static void main(String[] args) throws Exception { // TODO Auto-generated method stub increment obj =new increment(); obj.start(); synchronized(obj){ System.out.println("I am calling thread"); //obj.wait(); } } } class increment extends Thread{ public void run(){ synchronized(this){ System.out.println("Thread Called"); //this.notify(); } } } This is my code , my issue when main thread take lock of obj object synchronized(obj) and since i comment out obj.wait() that release lock over obj object. Then why synchronized block of increment class called. Output I am calling thread Thread Called But I think it should be I am calling thread Please help me to understand
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 4 жыл бұрын
Hello Ravi. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@rujutasamant8881
@rujutasamant8881 7 жыл бұрын
b is thread or object? How can we get lock on thread?
@raghavsingh3981
@raghavsingh3981 7 жыл бұрын
using sychronization
@MrShubhamenx
@MrShubhamenx 7 жыл бұрын
b is object. Thread always get a lock of "b" to get synchronized with the synchronized method called upon object "b".
@MrAbbydarappa
@MrAbbydarappa 6 жыл бұрын
B is a Thread agreed. But it's also an object. Since Thread Extends Object. In Java all Classes extends Object class by default.
@sagarparkale6380
@sagarparkale6380 6 жыл бұрын
Here we are using syntax in main() as, b.wait(); ie. we are calling methos wait() of object b, plz explain this to me i dont understand its meaning
@horriblecoder7280
@horriblecoder7280 6 жыл бұрын
we are calling wait method on object b. wait method belongs to Object class. Now since each class extends from Object class, by default each object gets wait method in its arsenal by inheritance.
@lorinamohanty6163
@lorinamohanty6163 8 жыл бұрын
I tried the above program just by omitting this.notify(), but still i found it is able to execute main thread completely. How come it comes out from the waiting state without calling notify() in child thread?
@mahesh_kok
@mahesh_kok 7 жыл бұрын
u must have used wait(time limit) so after time limit expires it will resume its execution.... if u have used only wait() in its lifetime it wont proceed.....
@dhrumilmevada4530
@dhrumilmevada4530 7 жыл бұрын
even i am not using wait(long t) method ,after commenting this.notify() it will work fine as work it work before . how? why ?
@royalzak4019
@royalzak4019 4 жыл бұрын
Sir i have a doubt in code that i have send u at ur gmail please reply soon.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 4 жыл бұрын
Hello Royalz AK. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@siddharathmehra4658
@siddharathmehra4658 7 жыл бұрын
i laughed so hard when students said , processor not gonna complete "for "loop in 10 seconds ,,,
@dailylifevlogger7258
@dailylifevlogger7258 6 жыл бұрын
Siddharath Mehra u do not know anything
@rajkoli8150
@rajkoli8150 5 жыл бұрын
Love u sir ..sir I am searching a job in java or web development sir pls help me to find job sir plss I want any location sir right now I am in pune
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 5 жыл бұрын
Hello Raj. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@khushboosharma5417
@khushboosharma5417 2 жыл бұрын
Sir can I get your mail I'd so that I can share my work with you and get resolved my doubts.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 2 жыл бұрын
Hello Sharma. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@Pushpendrasingh-gc4jh
@Pushpendrasingh-gc4jh 7 жыл бұрын
If Thread b don't call notify() method than my main Thread remain lifetime in waiting state,but it will execute why? class ThreadA { public static void main(String...arg) throws InterruptedException { ThreadB b=new ThreadB(); b.start(); synchronized(b) { System.out.println("main go for wait "); b.wait(); System.out.println("main get notification"); System.out.println(b.total); } } } class ThreadB extends Thread { int total=0; public void run() { synchronized(this) { System.out.println("child start"); for(int i=1;i
@Ganeshpatil-ow6ej
@Ganeshpatil-ow6ej 7 жыл бұрын
u got answer??? plz tell me i also have same dought
@malharjajoo7393
@malharjajoo7393 7 жыл бұрын
lol his stories are quite funny
@amanpainuly6796
@amanpainuly6796 7 жыл бұрын
Incorrect info. according to this guy. Notify() may release lock but not immediately...and wait(), notify() and notifyall() are the methods which releases lock. Which is totally incorrect as wait() is the only method which can release the lock..notify() and notifyAll() do not release the lock.if a thread calls notify() or notifyAll() on any object, the lock is released only in the two cases i). if thread completes its execution ii). if thread calls wait() after calling notify()/notifyall() That means, the lock is released by thread only in one condition..when is calls wait()
@monsieurmalandain
@monsieurmalandain 7 жыл бұрын
Any reference for your above statement? What we read from Oracle documentation below goes in favour of explanation in the above video. docs.oracle.com/javase/tutorial/essential/concurrency/guardmeth.html
Core Java with OCJP/SCJP: Multi Threading Part-12 || DeadLock || Starvation
55:06
Durga Software Solutions
Рет қаралды 216 М.
Core Java with OCJP/SCJP: Multi Threading Part-10 || Inter Thread Communication Part-1
1:18:26
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН
Core Java With OCJP/SCJP: Innerclass  Part- 1||Introduction
1:21:59
Durga Software Solutions
Рет қаралды 187 М.
Zelensky Announces Talks with Russia / End of Martial Law?
13:55
NEXTA Live
Рет қаралды 424 М.
Array vs. ArrayList in Java Tutorial - What's The Difference?
17:36
Coding with John
Рет қаралды 572 М.
Core Java with OCJP/SCJP: Multi Threading Part-7 || synchronization part-1
1:35:15
Durga Software Solutions
Рет қаралды 405 М.
Памяти Евгении Добровольской. Умерла 10 января 2025
37:45
Multithreading in Java Explained in 10 Minutes
10:01
Coding with John
Рет қаралды 992 М.
Fastest Way to Learn ANY Programming Language: 80-20 rule
8:24
Sahil & Sarra
Рет қаралды 947 М.
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН