🔥3 Ways to break singleton pattern | Solution of Problem in detail | Hindi

  Рет қаралды 43,660

Learn Code With Durgesh

Learn Code With Durgesh

Күн бұрын

Пікірлер: 42
@nikkm2000
@nikkm2000 9 ай бұрын
Gajab Tiwari ji. Dil jit liye. Tussi great ho. 🙂
@SreeTest-b6e
@SreeTest-b6e Ай бұрын
Gazab ka knowledge diya sir aapne.
@satendersingh2389
@satendersingh2389 5 ай бұрын
Lecture dekh ke samosa khane ka Mann horaha hai
@Romansoldier8888
@Romansoldier8888 8 күн бұрын
Timestamps 00:01 - Ways to break the singleton pattern 01:14 - There are multiple ways to break the singleton pattern 02:32 - Constructor in Singleton pattern 04:09 - There are two ways to avoid breaking the singleton pattern 06:19 - Two ways to break singleton pattern 09:15 - The solution to the problem is to overwrite the resolve method using Red Resolve technique. 12:52 - The method explained in the video helps in breaking the singleton pattern. 15:20 - Ways to break singleton pattern
@utkarshrazzz9964
@utkarshrazzz9964 Жыл бұрын
Appreciable sir, waiting eagerly for your next videos on this series.
@sgsenginier
@sgsenginier 3 ай бұрын
Awesome🙂Thanks.🙏
@nikkm2000
@nikkm2000 9 ай бұрын
small query- at 6:12 min---I have done below---two different instance created..... Constructor constructor = Samosa.class.getDeclaredConstructor(); constructor.setAccessible(true); Samosa s1= constructor.newInstance(); System.out.println(s1.hashCode()); Samosa s2= constructor.newInstance(); System.out.println(s2.hashCode());
@skaftab3954
@skaftab3954 7 ай бұрын
try this method: public class Samosa{ private static Samosa samosa; private static boolean objCreated=false; private Samosa() throws Exception { if (objCreated) { throw new Exception("One object already exists, you cannot call the constructor one more time"); } objCreated=true; }
@preranagayke1464
@preranagayke1464 Жыл бұрын
Hands of to your efforts
@himanshubaviskar3966
@himanshubaviskar3966 4 ай бұрын
Good Explanation 😊
@vaibhavkalyankar8650
@vaibhavkalyankar8650 4 ай бұрын
lol sir😃 @4:27 Ho gaya kaam tamam singleton ka 🤪 Nice sir
@sumitsaini-lo8ic
@sumitsaini-lo8ic 8 ай бұрын
Hi Durgesh, are you sure that if you are checking for null condition in the private constructor to prevent breaking the singleton pattern it will prevent breaking the singleton pattern?
@spider8015
@spider8015 6 ай бұрын
alag level sir aapka
@azaankhan0311
@azaankhan0311 6 ай бұрын
outstanding👍❤
@ravijaiswal9231
@ravijaiswal9231 7 ай бұрын
Samosha Khane ka man kar diya @Durgesh Bhaiya, raat hai milega bhi nahi🤤
@subhamgoswami8607
@subhamgoswami8607 Жыл бұрын
readResolve par detail video chaiye sir plz
@ketank6864
@ketank6864 Жыл бұрын
Thank you for awesome playlists
@rohitjaiswal946
@rohitjaiswal946 8 ай бұрын
Thanks for the great video, but I have one question, we are able to create multiple instances using reflection API even after adding the throwing exception in the constructor level. MyLazySingletonUnBreakable unBreakable2 = constructor.newInstance(); System.out.println(unBreakable2.hashCode()); //Here we are able to create another object MyLazySingletonUnBreakable unBreakable3 = constructor.newInstance(); System.out.println(unBreakable3.hashCode());
@skaftab3954
@skaftab3954 7 ай бұрын
hi, i got solution to your problem you have to add one more static boolean variable, here it goes: public class Student { private static Student stud; private static boolean objCreated=false; private Student() throws Exception { if (objCreated) { throw new Exception("One object already exists, you cannot call the constructor one more time"); } objCreated=true;// it will be true when constructor created for the first time so from next time the constructor is called it will give exception }
@MadhuKinneraDev
@MadhuKinneraDev Жыл бұрын
Great video sir.
@SaasBahuCares
@SaasBahuCares Жыл бұрын
A video on java-17 features pls ❤
@poorpanda9033
@poorpanda9033 10 ай бұрын
Thanks a lot
@qurashishebi7988
@qurashishebi7988 Жыл бұрын
keep it up
@varnitajaiswal8569
@varnitajaiswal8569 Жыл бұрын
nice video sir
@RishiRajxtrim
@RishiRajxtrim 8 ай бұрын
great
@rohandahiya6268
@rohandahiya6268 Жыл бұрын
What is double check locking and how is it better that single check locking ?
@UmeshMane-k7d
@UmeshMane-k7d 10 ай бұрын
Hi Sir, In Singleton design pattern could you please explan why we need to use "volatile" concept.
@suar_pilla
@suar_pilla 9 ай бұрын
bihari nehi janta
@mishra.pritam
@mishra.pritam 2 ай бұрын
so that al threads know the current value of samosa if made volatile
@monasoni4881
@monasoni4881 8 ай бұрын
good
@krishasharma_AJ
@krishasharma_AJ Жыл бұрын
Why we are using null check 2 times in get samosa method ?
@NidhiSharma-sw4oz
@NidhiSharma-sw4oz 11 ай бұрын
imagine both the threads are currently inside the 1st null condition. as soon as synchronised is there, thread t2 waits and t1 makes an object. now t1 has successfully made the object and come out of synchronised block. now t2 will go inside synchronised block. It would have tried to create another object BUT IT WAS NOT ABLE TO MAKE ANOTHER OBJECT BECAUSE OF 2ND NULL CHECK!!.
@gamerauto
@gamerauto 9 ай бұрын
@@NidhiSharma-sw4oz Wow Nidhi you're so smart, mamma would be so proud of you!
@vinaychauhan7627
@vinaychauhan7627 9 ай бұрын
Why dont we start our synchronized block from the first if condition.
@GeneralistDev
@GeneralistDev Жыл бұрын
What is the extension name which maek comments fire and terminal icons
@sandeepkumar-eq8nn
@sandeepkumar-eq8nn Жыл бұрын
Marunga mein he aur bachaunga bhi mein he
@kuldeepvm
@kuldeepvm 9 ай бұрын
You forgot to mention where that readResolve method is coming from.
@nsudhir_here
@nsudhir_here 6 ай бұрын
I am not a java person but I can guess that it comes from serializable interface.
@kuldeepvm
@kuldeepvm 6 ай бұрын
@@nsudhir_here nope. It's a marker interface.
@siddharthdandamudi6949
@siddharthdandamudi6949 4 ай бұрын
second point of Deserilization was confusing could have explained it better.
@sagardarade
@sagardarade 8 ай бұрын
With Deserialization Serialzation you did not explain how it's breaking singleton pattern.
🔥Lets understand Factory Design Pattern in Hindi
15:06
Learn Code With Durgesh
Рет қаралды 70 М.
🔥Singleton Design Pattern in Detail | Multi-Threaded Environments  | Hindi
25:59
Learn Code With Durgesh
Рет қаралды 106 М.
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
13. Java Singleton and Immutable Class Explained with Examples | Java Classes in Depth - Part4
28:26
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 903 М.
The Singleton Design Pattern - Part of the Gang of Four
28:41
IAmTimCorey
Рет қаралды 76 М.
This is the Only Right Way to Write React clean-code - SOLID
18:23
🔥Builder Design Pattern in Hindi | Design Pattern Series
16:24
Learn Code With Durgesh
Рет қаралды 42 М.
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН