Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two java threads at exactly same milli second

If two threads try to access the synchronized method at the VERY exact same time with exact milli-second or (whatever minimum CPU unit is).. What will happen? How JVM/System will resolve this issue if they have same priority as well. Will it create deadlock? Also, where this information about locks is stored?

like image 659
user1832435 Avatar asked Aug 26 '26 08:08

user1832435


1 Answers

That's the whole point of threading. The operating system's job scheduler will allow one to go before the other. No deadlock will occur.

Actually, the job scheduler is for heavyweight forking of processes. The JVM handles which Threads have a turn to execute or enter a synchronized block.

like image 199
asteri Avatar answered Aug 28 '26 00:08

asteri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!