Thank you for all of your videos. You are a fantastic teacher.
@aymanmouhcine57492 ай бұрын
Your analogy at the beginning helped me a lot to understand the concept. than you very much. I am watching the whole series.
@MihulBhattАй бұрын
Best java series on the internet.
@שוהםביטון-מ2כ8 ай бұрын
Thank you very much for all your clear and understandable explanations, You demonstrate and detail in a particularly understandable way!
@adhikaribinu743610 ай бұрын
Thanks for your video, i took a video in udemy, i just lost money, after discovering your videos :D I really love the simple way, you explained complex problem !
@AhmedElsaadany-ey7ri Жыл бұрын
The best explanation for race condition. keep going
@jenilcaptain629524 күн бұрын
Underrated !
@fahizkp47744 ай бұрын
Great explanation. Keep up the good work
@RishiRaj-xj2zb11 ай бұрын
Why when I try to execute by removing join of both the t1 and t2 , with sync method it prints count zero and if try to print the count by joining only one t1 and not t2 it comes near to 20000 not complete 20000?
@바다-r2y Жыл бұрын
Thanks a lot! It was really helpful.
@Vzletnýracek3 ай бұрын
thank you, awesome explanation!
@ShermukhammadKarimov7 ай бұрын
thanks for clear explanation
@ShermukhammadKarimov7 ай бұрын
thanks for the clear explanation one more time
@yikechen14708 ай бұрын
ur my heroo love from a cs kid
@mukulkarnwal145 күн бұрын
Please make a video for locks and semaphores.
@nerdium9705 Жыл бұрын
can volatile keyword used in this stuation instead of scynchronize? (int volatile count;)
@kalashjain3769 Жыл бұрын
Hello Sir , Very nice and beutiful explanation . Just a small thing regarding the code , that in my System I am always getting correct value without using synchronize keyword . So I can't visualize the race condition . Do you have any explanation about it . Thanks
@srikanthambati8976 Жыл бұрын
@Kalashjain.. I too get correct value with out using synchronize but it works for small iteration.. If we take more iterations like "2000" then it will give different value.
@rachel56283 ай бұрын
This is because the computation is simple and fast, and there is no thread switch that happens exactly at the critical section. Race condition may only show up in 1 in many times the program is run(depending on the complexity of ur program and num of threads) Add thread.sleep(1000ms) or very long for loop or some other artificial delay in your program to increase likelihood of thread switch and make the race condition obvious.
@evitaemort10 ай бұрын
amazing thank you!
@srikanthambati8976 Жыл бұрын
Instead of synchronized we can use setpriority to any of the thread to avoid conflicts.. This block of code works for me ## T1.setPriority(Thread.MAX_PRIORITY); T1.start(); T1.sleep(5); // sleep condition T2.start();
@sudhirthakur40354 ай бұрын
we cant use priority instead of sychronized because priority() doesnt support windows and give mixed output for same code whereas synchronized maintains no data inconsistency and thread interference .
@maleeshasandakalum6213 Жыл бұрын
Thank you sir❤❤
@ayushisingh66385 ай бұрын
what is the use of volatile?
@ragavir2601 Жыл бұрын
I am getting error as "Error: Could not find or load main class mythread", when i try executing the code
@rockingstars4121 Жыл бұрын
sir is there any logical mistake in my code : class rider{ int count;// as it is an instance variable so it is by default zero public synchronized void increment(){ count++; } } class A extends rider implements Runnable{ public void run(){ for(int i=1;i{ for(int i=1;i
@NahiRahman-jr3cs3 ай бұрын
i am getting 19998 instead of 20000 even with the synchronized implementation, can you tell me why?
@NaveenKumar-hy5et Жыл бұрын
class Counter{ int count; public void increment(){ count++; } } public class Main { public static void main(String args[]) { Counter c = new Counter(); Runnable call = () -> { for (int i = 0; i < 100; i++) { c.increment(); } }; Runnable call2 = () -> { for (int i = 0; i < 100; i++) { c.increment(); } }; Thread t1 = new Thread(call); Thread t2 = new Thread(call2); t1.start(); t2.start(); System.out.println(c.count); } } why am i getting (0)
@aszaw5342 Жыл бұрын
Because java printing c.count when was 0 and before any thread tasks
@yogeshwaran7443 Жыл бұрын
I also get 0😅 then i am using sleep for 10000ms before print count Then get 2000 as output