Hello, someone who know threads and avoid undefine...
# random
p
Hello, someone who know threads and avoid undefined results on critical variables? For example if thread 1 have aquired a lock for "critical section X" and executes in the "critical section X". When the thread 1 executes in the "critical section X", thread 2 would also like to enter the "critical seciton X". Then, thread 2 tries to aquire that lock that belongs to the "critical section X", but the lock is already locked. What will happend to thread 2 then????? Will it spin in an extremely CPU-consuming loop until thread 1 unlock the lock? Or what is going to happend? Or what things would we like to happend with thread 2 in the meantime?
a
Thread 2 will just sleep and wait until Thread1 releases the lock
👍 1
presuming you are using
synchronized(..) { }