Sample Header Ad - 728x90

Race conditions. When 2 thread try to update in same entity in table

1 vote
1 answer
4663 views
We all know that race condition is something we should avoid. We should not try to access the same variable or memory when using multiple threads. But I have some tricky cases. Let's say we have a user table.
user id | name | age

1       | Paul | 14
What if One thread try to update "name" column, and The other thread tries to update "age"? Is this always safe? --- ***Additional Question,*** Let's say that there is some really bad query that it will take 20 seconds to get a result. If one thread run this SQL query, and the other thread wants to run another SQL query. The other thread should wait 20 seconds? (till the previous query finish its job)
Asked by Jin Lim (121 rep)
Mar 12, 2022, 12:32 PM
Last activity: Mar 22, 2022, 11:09 PM