best yt channel for design patterns , thank you! great job!
@marcobaccaro3 жыл бұрын
That’s a classic book. Singleton, the pattern anti-pattern :) Good content...
@MrEditorBen3 жыл бұрын
Great job. Helped cleared some confusion on this concept
@BeABetterDev3 жыл бұрын
Glad you found this useful DragonLord!
@nirmesh444 жыл бұрын
great work buddy
@vanamutt433 жыл бұрын
great tutorials dude, so few views but so so good. thanks mate. also, you kinda look like the doctor dude from walking dead, siddiq i think his name was:D anyways, thanks again mate
@prabhatism2 жыл бұрын
The if condition should be inside the synchronised block?
@fyh88483 ай бұрын
keep original if-check, then add another if-check in synchronized block.
@shivambaghel966821 күн бұрын
yes that if cond should be in sunchronized block as when we create 2 thread (e.g.) both check for null and enter in synchronization block simultaneuosly and create 2 instance with different hashcode.. code here .. public class Main implements Runnable{ @Override public void run() { DataBaseConnectionManager obj = DataBaseConnectionManager.getInstance(); System.out.println("Thread running for "+obj.hashCode()); } public static void main(String[] args) { Thread t1 = new Thread(new Main()); Thread t2 = new Thread(new Main()); t1.start(); t2.start(); try{ t1.join(); t2.join(); }catch (InterruptedException e){ e.printStackTrace(); } } } output Thread running for 687105320 Thread running for 1582306442
@khomo12 Жыл бұрын
Nice👍👍
@hectorprx4 жыл бұрын
Thanks
@mananabanana4 жыл бұрын
You forgot to update the description. :)
@BeABetterDev4 жыл бұрын
Thank you !
@LilMartyFarty3 жыл бұрын
Why would you not wrap all of the code in synchronized?
@bity-bite3 жыл бұрын
Why not just make it static?
@vanamutt433 жыл бұрын
because static doesnt instantiate, singleton is useful when you want an instance but just one
@fyh88483 ай бұрын
you could but instance will be created always when class is loaded. If it is no need, then resource is wasted.