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.
@abarag87 жыл бұрын
Dreamer sharma I
@sankalparora93742 жыл бұрын
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.
@DurgaSoftwareSolutions2 жыл бұрын
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
@gwalaniarun6 жыл бұрын
I watched telusko videos because of duration time but your quality of teaching worth this time. Thanks.
@venkatasudheerkavuru56664 жыл бұрын
Bro which one is better
@yoshitamahajan3534 жыл бұрын
@@venkatasudheerkavuru5666 I thik durga soft videos are way better to understand the concept..
@sudhanshuprakash23134 жыл бұрын
Durga sir is the best teacher I have seen in my entire life.
@DurgaSoftwareSolutions4 жыл бұрын
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
@vincentmax45716 жыл бұрын
You are one of the greatest living human. Respect for your passion for teaching and that style. Love you sir.
@DurgaSoftwareSolutions6 жыл бұрын
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
@skarre874 жыл бұрын
Durga sir is best at doing postmortem...Love to watch ur tutorials...Mind blowing work sir....Thanks for all this content you provide.
@DurgaSoftwareSolutions4 жыл бұрын
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
@mrProgrammingGeek4 жыл бұрын
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_World7 ай бұрын
I had same doubt. Thanks for Clarifying.
@sakshiaggarwal38386 жыл бұрын
Durga Sir ! You are "THE BEST"
@DurgaSoftwareSolutions6 жыл бұрын
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
@tharunkumar274 ай бұрын
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.
@DurgaSoftwareSolutions4 ай бұрын
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
@eadunuripranay59774 жыл бұрын
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.
@DurgaSoftwareSolutions4 жыл бұрын
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
@debaduttapanda91736 жыл бұрын
Thanks a lot sir...coz of u like we people from non branch also can understand the complete terminology......... U R simply BEST
@DurgaSoftwareSolutions6 жыл бұрын
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
@niloymridha17174 жыл бұрын
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.
@DurgaSoftwareSolutions4 жыл бұрын
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
@niloymridha17174 жыл бұрын
@@DurgaSoftwareSolutionsCan you tell me how can i meet with durga sir please?
@mayurthetraveller8 жыл бұрын
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 :)
@DurgaSoftwareSolutions8 жыл бұрын
Thank u Mayur... Plz keep watching our videos on You Tube.
@kumarvelu5 жыл бұрын
Durga sir giving left and right to threads.
@DurgaSoftwareSolutions5 жыл бұрын
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
@akashkala92993 жыл бұрын
haha Epic :)
@amolsathewad75948 жыл бұрын
Hats off to Durga sir....Thanx for providing quality teaching
@DurgaSoftwareSolutions8 жыл бұрын
Hi Amol.. thank your for you feedback
@pushparay55547 жыл бұрын
Sir huge respect to you. The best teacher you are!!!!!!
@utkarshsalaria39523 жыл бұрын
Sir your explanation is great!! NO ONE TEACHES THAT WELL..✌👍
@DurgaSoftwareSolutions3 жыл бұрын
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
@hi10drakk3 жыл бұрын
Please add keywords - wait, notify, notifyall, producer consumer by durga sir himself - the Java god
@m.smanoj4688 Жыл бұрын
in multithreading this is one of the difficult concept with durga sir therse no word for difficulty😁😁😁😁😁😁
@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 Жыл бұрын
comparing sleep(), join(), wait() - 17:00 - 21:55
@divyadixit46986 жыл бұрын
thanks alot sir ji nobody teaching like you you are man kind angel
@DurgaSoftwareSolutions6 жыл бұрын
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
@divyadixit46986 жыл бұрын
thanks sir my pleasure
@coolprashantmailbox8 жыл бұрын
awesome video..thank u for uploading by Durgasoft
@DeepakKumar-dw1re2 жыл бұрын
Mst Durga sir😎
@abhijitchikane5 жыл бұрын
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?
@DurgaSoftwareSolutions5 жыл бұрын
Hello Abhijit. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@anupamawasthi125 жыл бұрын
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.
@mohanrajs99174 жыл бұрын
Thank you so much sir, this session is very understandable.
@DurgaSoftwareSolutions4 жыл бұрын
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
@rizwanshahid14477 жыл бұрын
Thanks so much, Durga Sir.
@manassahoo27502 жыл бұрын
Thank you very much sir ❤️
@thinksix19254 жыл бұрын
Thanks for teaching sir 🙏
@fathimafathima16812 жыл бұрын
1:04 - difference between notify and notifyAll
@somubolla21618 жыл бұрын
Please upload Core Java with OCJP/SCJP: Multi Threading Part-11 || Inter Thread Communication Part-1 don't forget to upload Part 1
@ranveervaghela70305 ай бұрын
Completed watching on 06-08-2024 at 5.45 pm
@rakhigandhi68025 жыл бұрын
Great video!
@DurgaSoftwareSolutions5 жыл бұрын
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
@prabhudeepsingh42367 жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
Hello Durga Sir, 25:01 why we make synchronized(b) ?? Can't we make synchronized(this)??
@DurgaSoftwareSolutions Жыл бұрын
Hello Friend. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@its_rk2448 Жыл бұрын
To particularly mentioning a object we have to write it.. If it is the one object then u can use this
@sug_madic76834 жыл бұрын
52:24 this is the reason you came for
@sug_madic76833 жыл бұрын
I cant believe that i got an heart I was just chilling in my holidays to learn something new
@akshaybhoi80923 жыл бұрын
Dear durga Sir , please make some videos on REFLECTION API. do postmottom on that topic. please sir....
@malharjajoo73937 жыл бұрын
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-x3p11 ай бұрын
We can call join method too to get the correct output
@vivekbudge97064 жыл бұрын
Thank you so much sir
@rupeshgaming1604 Жыл бұрын
Jay Jagannath 💜
@benzo_uncle6 жыл бұрын
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!!
@programmer66493 жыл бұрын
Paina kinda voopu durga sir java lo thopu 😂😂
@EngineerVaibhav Жыл бұрын
91th video🎥🎉❤
@utkarshsalaria39523 жыл бұрын
sir please provide one example of notifyAll() method
@sheelstera6 жыл бұрын
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 ... .. . }
@saurabhdsawant5 жыл бұрын
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 .
@sheelstera5 жыл бұрын
@@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..
@adhwareshpandey26358 жыл бұрын
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.
@mayurthetraveller8 жыл бұрын
thank you so much for being here for...
@rajyasriashok11546 жыл бұрын
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_shubh6 жыл бұрын
The wait() method will immediately releases the lock of the object.
@ratimohan57656 жыл бұрын
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??
@DurgaSoftwareSolutions6 жыл бұрын
Hello Mohan. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627,7207212427/28
@राजनगोंगल Жыл бұрын
👍👍👍👍👍👍
@TheSarthak4256 жыл бұрын
Thank you sir!
@saurabhgupta20577 жыл бұрын
please explain volatile.. coz it is very important for interview
@pranapsahoo79807 жыл бұрын
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.
@deepakpatre48745 жыл бұрын
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).
@DurgaSoftwareSolutions5 жыл бұрын
Hello Deepak. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@pavithrasenthil70934 жыл бұрын
sir,why synchronization in both child and parent class compulsory required
@DurgaSoftwareSolutions4 жыл бұрын
Hello Pavithra. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@christopherami81424 жыл бұрын
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...
@pavithrasenthil70934 жыл бұрын
@@christopherami8142 thank you 👍
@prathi12125 жыл бұрын
wait() is not a native method right? Why is the console showing java.lang.Object.wait(native method) ? At 23:34
@DurgaSoftwareSolutions5 жыл бұрын
Hello Prathibha. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@somubolla21618 жыл бұрын
Need to upload Inter Thread Communication Part- 1 please
@renjithr76765 жыл бұрын
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?
@DurgaSoftwareSolutions5 жыл бұрын
Hello Renjith. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@shankars42814 жыл бұрын
Same doubt for me, what if child thread gets executed first and gets the lock of object b ?
@vasireddyganesh4 жыл бұрын
@@shankars4281 same doubt...bro...Can u plz clear my doubt ...if ur doubt got clarified...
@sripolisettys3 жыл бұрын
@@vasireddyganesh watch 37:00
@AJAYKUMAR-lp6sv Жыл бұрын
Does it get resolved or not buddy ..I have the same issue
@vishalgadapa78694 жыл бұрын
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.
@DurgaSoftwareSolutions4 жыл бұрын
Hello Vishal. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@nithinreddy12422 жыл бұрын
I wonder how join() method is able to call wait(0) internally from non-synchronized are😮
@amolsathewad75948 жыл бұрын
sir ...please upload All Swing video by durga sir
@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 Жыл бұрын
Hello Venkat. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@devashishchoubey19656 жыл бұрын
thnx sir
@vaibhavpal16 жыл бұрын
Thankyou sir
@DurgaSoftwareSolutions6 жыл бұрын
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
@PandeyRavindra18 жыл бұрын
amazing explanation sir.....
@saritasrivastava45996 жыл бұрын
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.
@DurgaSoftwareSolutions6 жыл бұрын
Hello Sarita. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@MrSahilkaura6 жыл бұрын
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?????
@bipinsingh14905 ай бұрын
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
@DurgaSoftwareSolutions5 ай бұрын
Hello Friend. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@n.rukkumani72978 жыл бұрын
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
@vishalaggarwal15738 жыл бұрын
definitely the child thread may execute first but to show programmatically sir did this..
@n.rukkumani72978 жыл бұрын
thank u
@johnwickgaming69385 жыл бұрын
It depends on thread scheduler
@nandamudiravali23827 жыл бұрын
is there any possibility to run another thread while one thread is in sleep
@ramandeepdhir97956 жыл бұрын
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();
@prakharjha71766 жыл бұрын
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 Жыл бұрын
43:40 🤣🤣🤣🤣🤣🤣🤣
@koppulapramod5546 жыл бұрын
What happen if child thread got the chance instead of main thread??
@DurgaSoftwareSolutions6 жыл бұрын
Hello Pramod. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627,7207212427/28
@Ganeshpatil-ow6ej7 жыл бұрын
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-pq5uy7 жыл бұрын
At 44:00 full of hair and so on.. are you main ? hahah!!
@adishjain25078 жыл бұрын
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-vs6yf8 жыл бұрын
HI Durga Sir please clarify this point
@ArunraajSingh8 жыл бұрын
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_kok7 жыл бұрын
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
@MrShubhamenx7 жыл бұрын
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.
@pratikbhardwaj38047 жыл бұрын
only wait notify and notifyall methods can leave the lock , no other methods in java
@sobhan347 жыл бұрын
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
@kumarsantoshdash7 жыл бұрын
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/
@MrShubhamenx7 жыл бұрын
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.
@deepakbansal9006 жыл бұрын
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.
@rakeshkumarparida984 жыл бұрын
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
@DurgaSoftwareSolutions4 жыл бұрын
Hello Rakesh. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@ravishekhar14284 жыл бұрын
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
@DurgaSoftwareSolutions4 жыл бұрын
Hello Ravi. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@rujutasamant88817 жыл бұрын
b is thread or object? How can we get lock on thread?
@raghavsingh39817 жыл бұрын
using sychronization
@MrShubhamenx7 жыл бұрын
b is object. Thread always get a lock of "b" to get synchronized with the synchronized method called upon object "b".
@MrAbbydarappa6 жыл бұрын
B is a Thread agreed. But it's also an object. Since Thread Extends Object. In Java all Classes extends Object class by default.
@sagarparkale63806 жыл бұрын
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
@horriblecoder72806 жыл бұрын
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.
@lorinamohanty61638 жыл бұрын
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_kok7 жыл бұрын
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.....
@dhrumilmevada45307 жыл бұрын
even i am not using wait(long t) method ,after commenting this.notify() it will work fine as work it work before . how? why ?
@royalzak40194 жыл бұрын
Sir i have a doubt in code that i have send u at ur gmail please reply soon.
@DurgaSoftwareSolutions4 жыл бұрын
Hello Royalz AK. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@siddharathmehra46587 жыл бұрын
i laughed so hard when students said , processor not gonna complete "for "loop in 10 seconds ,,,
@dailylifevlogger72586 жыл бұрын
Siddharath Mehra u do not know anything
@rajkoli81505 жыл бұрын
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
@DurgaSoftwareSolutions5 жыл бұрын
Hello Raj. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@khushboosharma54172 жыл бұрын
Sir can I get your mail I'd so that I can share my work with you and get resolved my doubts.
@DurgaSoftwareSolutions2 жыл бұрын
Hello Sharma. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@Pushpendrasingh-gc4jh7 жыл бұрын
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-ow6ej7 жыл бұрын
u got answer??? plz tell me i also have same dought
@malharjajoo73937 жыл бұрын
lol his stories are quite funny
@amanpainuly67967 жыл бұрын
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()
@monsieurmalandain7 жыл бұрын
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