Тёмный

Core Java With OCJP/SCJP: Multithreading Enhancement Part- 3|| java.util.concurrent.locks 

Durga Software Solutions
Подписаться 831 тыс.
Просмотров 147 тыс.
50% 1

java
Basic Java Tutorial for beginners
Basic Java Programming for beginners
Core Java By Durga Sir
Core Java
Core Java Video Tutorials
Core Java Tutorial for beginners with examples
Core Java Tutorial
Core Java DURGASOFT
Durgasoft Core Java
Durgasoft Java
durga software solutions core java videos
durga software solutions java
How to learn java
How to learn java programming language for beginners
learn java
learn java programming for beginners
programming in java
understanding java
java application development tutorial
java beginner tutorial
java basics for beginners
java for beginners
java lessons
java lectures
java language tutorial for beginners
java programming tutorial
java programming for beginners
java tutorial for beginners
java tutorial
java tutorial by durga sir
====================================
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

Опубликовано:

 

30 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 91   
@PineshMenat86
@PineshMenat86 6 лет назад
MultiThreading Enhancement Written Notes: drive.google.com/open?id=1HSiNMLdBlz6F3bDHD3qkYoEgKx_QLpX0
@jinitescapematrix
@jinitescapematrix 2 года назад
can you please share again
@ranveervaghela7030
@ranveervaghela7030 Месяц назад
Completed watching on 24-08-2024 at 12.13 PM :)
@EngineerVaibhav
@EngineerVaibhav Год назад
97th video completed❤🎉
@shraddhasiddhe
@shraddhasiddhe Год назад
I Just completed the 97th video you're not alone 🎉
@DeepakKumarRout-h6t
@DeepakKumarRout-h6t 9 месяцев назад
Where I can found Executor Frameworks Videos
@mayankkumar7338
@mayankkumar7338 6 лет назад
synchronized keyword can only lock the owner object not any object other, but l.lock() can block any object on which the method wish is called although Durga sir has used only one object in the Demo of locks for Display class object, If they were two different objects then the program would result in unexpected output in case of synchornized, But as for wish with l.lock() method it would give expected results irrespective of on how many different objects you are calling the wish method.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 6 лет назад
Hello Mayank. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627,7207212427/28
@guddantianirudh9161
@guddantianirudh9161 Год назад
but i got irregular output by starting two threads with two different objects. May i know the reason?
@m.smanoj4688
@m.smanoj4688 Год назад
nothing is difficult when durga sir is teaching. i even saw udemy courses they make things complex there but these advance concept was explained superbly pls provide your google or phonepe no so that i can contribute some amount as a tribute to your way of teaching and explantaion
@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
@sriman__1793
@sriman__1793 6 дней назад
What is the need of creating constructor when we're not creating object
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 5 дней назад
Hello Sriman. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@prasanjeetchakravarty6696
@prasanjeetchakravarty6696 3 года назад
Sir your Teaching is just like a butter. Great Explanation sir
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 3 года назад
Hello Chakravarty. 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
@m.smanoj4688
@m.smanoj4688 Год назад
Father of the language is JAMES GOSLING BUT LENGENDS OF LENGEND IN TEACHING JAVA IS DURGA SIR
@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
@rangaswamymaddileti9751
@rangaswamymaddileti9751 Год назад
1:16:50
@Shashank.tiwari4
@Shashank.tiwari4 2 года назад
Explanation by @Durga sir is just wonderful .One of the best teacher for Java in the country. Waiting for tutorial on semaphore ,countdown latch and cyclic Barrier.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 2 года назад
Hello Shashank. 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
@edeepakjain
@edeepakjain 5 лет назад
Sir pls clip wait clips where you are not explaining so that these sessions can be short.
@rastemmilengephirchltechlte
@rastemmilengephirchltechlte 4 года назад
Believe me guys these 3 lectures which durga Sir teach after threading topic (96-97-98) it is pure gold and diamond, In which project am working now there one platform code is almost 18gb, 12gb.16gb etc and I can see every topic which durga Sir teach it is on there in code, but this trylock(), lock(), unlock() is not there in code. it is show what durga Sir teach us in free And his every word is correct mostly people don't know about it and used synchronized everywhere.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 4 года назад
Hello Santosh. 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
@balamurugan2785
@balamurugan2785 5 лет назад
Perfect video ! Love from TamilNadu :-) Durga Sir
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 5 лет назад
Hello Bala Murugan. 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
@shashavalijava9
@shashavalijava9 Год назад
A thread can occure same lack multiple times without any issue. Internal reentrate lock
@sumitbadugu417
@sumitbadugu417 Месяц назад
Please Make videon DSA
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions Месяц назад
Hello Sumit. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@VishalSharma-rn7mt
@VishalSharma-rn7mt 4 года назад
Great Video Sir, Thank you for making this video. Love from Bihar
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 4 года назад
Hello Vishal. 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
@PhaniSoftTech
@PhaniSoftTech 6 лет назад
Awesome sir. But having 1 doubt. Why we are use l.lock() multiple times. Where we need to use this type of mechanism? Can any one tell me.
@sanpanchapakesan7654
@sanpanchapakesan7654 5 лет назад
The actual purpose of ReentrantLock class is to show or demonstrate that a Thread can acquire many lock on the same rl object....and release the lock and while releasing it is released in the exact reverse order.. 1, 2, 3....3, 2, 1. This is not possible in the traditional synchronized keyword... Hope i am clear... Thank you...
@damodaragottipalli5484
@damodaragottipalli5484 7 лет назад
Why static is required for this statement "static ReentrantLock r = new ReentrantLock();"?
@pornsasa
@pornsasa 6 лет назад
By using static keyword, all objects(t1, t2) will have to share the same lock. Static gives class level lock. If you don't use static keyword, since t1 and t2 are different objects they will have different locks so they can run simultaneously. details: stackoverflow.com/questions/5678741/does-making-a-reentrant-lock-static-and-make-it-a-mutex
@sanpanchapakesan7654
@sanpanchapakesan7654 5 лет назад
Mr Damodaran, If there is a static variable or object say 'm' in a class X....then m is for the class X and for all the objects of the class... They all will have to share m. In this case the static rl object will be for both threads t1 and t2.... Hope I am clear..Thank you...
@ashokmandadi
@ashokmandadi 5 лет назад
As per my understanding,since ReentrantLock is static ,ReentrantLock object is common to those 2 threads
@Sujittt_Patil
@Sujittt_Patil Год назад
1:16:50
@m.smanoj4688
@m.smanoj4688 Год назад
saw many recommendations in instagram ans many recommendations in many websites but no one mentions this channel or recommends to watch it i dont know why though the videos are lengthy but i bet u will get divine understanding even a non tech or non it student can understand
@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
@sanpanchapakesan7654
@sanpanchapakesan7654 5 лет назад
In the do..while example the if and else have come inside try, because the method call tryLock(with argument shall throw an IException)....
@sanpanchapakesan7654
@sanpanchapakesan7654 5 лет назад
Thread.sleep() also can throw IException.... this is the reason both have come inside try...
@asharanimahapatra.2608
@asharanimahapatra.2608 5 лет назад
Why in the demo program for tryLock() method, we take object creation of ReentrantLock class as static?
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 5 лет назад
Hello Asharani. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@vinayguptha8810
@vinayguptha8810 5 лет назад
As two threads are executing simultaneously and we want to have same lock reference for both the threads so it was declared with static.
@eadunuripranay5977
@eadunuripranay5977 4 года назад
@@vinayguptha8810 what happens if we remove static there and wt wud be the change and explain the functionality plz ?
@narendrachowdary6894
@narendrachowdary6894 4 года назад
@@eadunuripranay5977 static method belongs to the class If we remove static two threads will have two different objects and there will be irregular output So hence reentrant is static it will hold memory only when the class is started so two threads will have same reentrant lock
@haykmkrtchyan7093
@haykmkrtchyan7093 2 года назад
Well, you can create your Runnable implementation, where the ReentrantLock won't be static. You can create 2 different threads and pass the same runnable.
@sanpanchapakesan7654
@sanpanchapakesan7654 5 лет назад
Durga Sir, Good Evening, For the third example i.e, tryLock()...If run() has a loop of 5 executions, it looks better. I am sending the code please correct me...Thank you public void run() { for(int i=0; i
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 5 лет назад
Hello San. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@eadunuripranay5977
@eadunuripranay5977 4 года назад
i don't think so this code proves this concept i mean unwanted stuff has been written more.....when both the threads get started... one enters into if loop & other enters into else ....so when loop of 5 times is written.....one thread executes once in if stmt and sleeps...by that time other thread finishes its 5 time loop execution n terminates & what is the meaning of first thread keeps on looping for nother 4 times by releasing & acquiring?
@sandhya6356
@sandhya6356 4 года назад
Thank you..! Sir again🙏🙂
@vivekbudge9706
@vivekbudge9706 4 года назад
Thank you so much :)
@prasadmahakal2361
@prasadmahakal2361 Год назад
Thank uhh God Of JAVA @durgasir
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions Год назад
Hello Prasad. 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
@vinothm5764
@vinothm5764 7 лет назад
The number of views for advanced concepts has decreased tremendously. People are starting with first few videos and giving up when it comes to tougher concepts.
@sathyareddy3272
@sathyareddy3272 7 лет назад
It's there loss, one should have passion to learn and understand new things and if your passionate about it then you would never give up on it.....
@sandeepe5989
@sandeepe5989 6 лет назад
very valid point ....it shows am also strong...:-)
@vivek5562
@vivek5562 4 года назад
This is my 1st video
@akhiljaiswal9468
@akhiljaiswal9468 4 года назад
sir is giving his best to make everyone clear with java concepts but viewers are not serious at all . they start watching videos with great zeal at the beginning but lose their enthusiam to learn very soon that's why they face problem.if someone is really keen to learn java then completing all the videos of durga sir is a good examination to check his/her dedication and commitment.
@damodaragottipalli5484
@damodaragottipalli5484 7 лет назад
nice videos by Durga. He is the java Doctor of all Java patients.
@rajatgoyal1491
@rajatgoyal1491 4 года назад
In synchronization we were getting lock over a particular method of the object or lock in a particular block. But here 15:00 on which thing we are getting the lock
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 4 года назад
Hello Rajat. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@eadunuripranay5977
@eadunuripranay5977 4 года назад
we get the lock of the ReentrantLock object when thread calls any method of ReentrantLock class.
@Lakshmankablog
@Lakshmankablog 2 года назад
👌👏🤩🥳 superb
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 2 года назад
Hello Lakshman. 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
@abhay1893
@abhay1893 6 лет назад
Doubt at 1:25:33 : "Unable to get lock and will try again" is not showing 6 times it is 5 times, is it correct?
@renjithr7676
@renjithr7676 5 лет назад
I also had the same doubt, I found an answer for this question. t1 is getting lock and enters the block t2 is coming on the same time or some time after t1 then right(difference of nano seconds) otherwise t2 would have acquired the lock. when t2 timeout for trylock method it is executing few lines and again calling trylock().Executing these lines are expensive (of course there are sout also). so each loop has 5 sec + nanoseconds and 6*(5+nano seconds) > 30 seconds .
@max27lab56
@max27lab56 3 года назад
truly great
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 3 года назад
Hello Friend. 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
@राजनगोंगल
👍👍👍👍👍👍
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions Год назад
Hello Friend. 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
@ishan6888
@ishan6888 6 лет назад
why tere is need to have no of lock for same thread...why it is needed?
@MrSahilkaura
@MrSahilkaura 4 года назад
Well, I also have same doubt.
@hellofrnd2
@hellofrnd2 8 лет назад
In the do while example , the second thread is executing the alternative operation of else again and again till it aquires the lock. Is it a good practice that the thread has to perform this alternative operation again and again unnecessarily? the whole meaning of lock system here is that thread does not have to wait and can perform any alternative operation. but here the thread has to perform that alternative operation again and again to get the lock. Can someone please clarify my doubt ?
@manish2aug
@manish2aug 7 лет назад
It's a particular example to explain the use of tryLock() method, I am sure in real time scenario alternate operation would not be a console output statement, he chose the example to explain the use but deciding alternate operation is application specific and cannot be generalize
@sanpanchapakesan7654
@sanpanchapakesan7654 5 лет назад
Gentle man, The call of sleep and the repeated alternate operation is to demonstrate (that one thread is having so much code to execute. OBJECT STATE CHANGING CODE..) else is happening when lock is not available...but in real life applications the thread which has not got the lock will go ahead and compete its NON-STATE CHANGING job...other wise we can attempt the lock again somewhere else in the code where the other thread will perform the lock oriented operations(OBJECT STATE CHANGING jobs)....
@kumarsantoshdash
@kumarsantoshdash 7 лет назад
Sir, How to get class level lock using java.util.concurrent ?
@prashantgupta3236
@prashantgupta3236 7 лет назад
In my opinion, you can use the same logic in static method (instantiating the lock object and using it). so whatever is going to call your static method, will have to wait for the lock on the lock object.
@AnishAgarwal
@AnishAgarwal 5 лет назад
try making lock itself static...
@bittukush2009
@bittukush2009 6 лет назад
why do we require multiple locks on same object by same thread,please clarify?
@sanpanchapakesan7654
@sanpanchapakesan7654 5 лет назад
This is an enhancement...multiple locks by a thread on the same object was not possible in the traditional way... Thank you...
@neerajagandla4366
@neerajagandla4366 5 лет назад
@@sanpanchapakesan7654 Yeah. But how can we make use of such enhancement? In which cases do we need multiple locks on same object by same thread in reality?
@sanpanchapakesan7654
@sanpanchapakesan7654 5 лет назад
@@neerajagandla4366 In one single transaction (a single object) where you buy different items from different windows. But bill is on the same object. This is a sample situation.
@neerajagandla4366
@neerajagandla4366 5 лет назад
But if a thread already has a lock on an instance, it doesn't need to acquire the lock on the same object again right. Can you please demonstrate with a code example?
@umeshpatnaik5174
@umeshpatnaik5174 4 года назад
Hi Durga sir , Thanks for your videos that which are the best in knowledge .. package conn.lock; import java.util.concurrent.locks.ReentrantLock; public class ReenterantLocks { public static void main(String[] args) { Display d= new Display(); MyThread t1= new MyThread(d, "Dhone"); MyThread t2= new MyThread(d, "Yuvraj"); t1.start(); t2.start(); } } class MyThread extends Thread{ Display d; String name; static ReentrantLock lock=new ReentrantLock(); public MyThread(Display d,String name) { // TODO Auto-generated constructor stub this.d=d; this.name=name; } @Override public void run() { // TODO Auto-generated method stub lock.lock(); d.wish(name); lock.unlock(); } } class Display{ public static void wish(String name) { for (int i = 0; i < 10; i++) { System.out.print("Good morning"); try { Thread.sleep(2000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("::"+name); } } } I had a doubt whether the lock is at object level or class level as the method is static ..
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 4 года назад
Hello Umesh. 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
@mohendraamatya1958
@mohendraamatya1958 3 года назад
@Umesh I believe its a class level lock, you can check by using two display objects.
@abarag8
@abarag8 7 лет назад
This is highly informative. Such an advanced topic explained in a simple way...Thank you Durga sir... you are a legend...JAVA MEANS DURGA :)
Далее
荧光棒的最佳玩法UP+#short #angel #clown
00:18
# Rural Funny Life Wang Ge
00:18
Просмотров 750 тыс.
Java Multithreading Semaphore example
14:56
Просмотров 16 тыс.