actually now only I understand the double-checked locking of the singleton class, the way you explained the thread's behavior is Awesome. (except the last part cache). Thanks a ton for this great lecture. 🙂🙂🙂
Because of you guys I have become so much confident in Java ! I was good at dsa but you guys helped me a lot while cracking interviews of Accenture, Infosys, global logic and 7 others. Can't thank you enough
As far as i know if a code block is synchronized then only one thread can access it even if there are multiple thread running. Once a thread leaves that block only then other thread can access that block. If i am not wrong then is contradicts the volatile part of the video. Please correct me if i am wrong. Also thanks a lot for your videos.
can you please answer this as you explain the use case of volatile but that should only arise when two thread's are accessing the same block at same time or preemption is happening but in any case the synchronised block must now allow the other thread to access because of the lock mechanism hence i am unable figure why you may want to use volatile here