JusticeTech System
الذهاب إلى القناة على Telegram
Learn to learn before you teach
إظهار المزيدلم يتم تحديد البلدالفئة غير محددة
227
المشتركون
لا توجد بيانات24 ساعات
-17 أيام
+230 أيام
أرشيف المشاركات
🍄 If you are a Telegram Premium subscriber, boost our channel.
🚨 Tap here: https://t.me/boost/justicetechsystem
🏡 It's free to tap.
Also state out any topic you'd want me to teach, if it falls within my ability I'd teach it to the best of my knowledge
Here's the mental model I want you to keep:
A race condition is basically a fight over information.
The computer doesn't necessarily care about your intention. It executes instructions according to timing and scheduling.
If someone asks you henceforth "What is a race condition?"
A strong beginner answer is:
A race condition is a programming problem that occurs when multiple processes, threads, or requests access a shared resource at the same time, and the final result depends on the order or timing of those operations.
And always remember the formula:
Multiple actors + Shared resource + Simultaneous access + Poor synchronization = Race condition
Where Do Race Conditions Happen?
They're especially common when dealing with:
Threads: Multiple threads can execute at overlapping times.
Processes: Multiple processes can access shared resources.
Databases: Multiple users can modify the same records.
Servers: Thousands of users can send requests simultaneously.
Distributed systems: Different computers can perform operations at the same time.
Files: Two programs may attempt to modify the same file.
Shared memory: Multiple workers can read/write the same memory.
That was what I was explaining herehttps://t.me/justicetechsystem/2163
Go through all the mechanisms and you'd understand better
Programmatically can do something like this below
For example, conceptually:
lock.acquire()
balance = balance - 7000
lock.release()
The lock basically says "I'm using this shared resource. Everyone else, wait."
The basic idea is:
Don't allow two operations to modify the shared resource at the dangerous moment.
But how?
This can actually happen in different places like online stores, ticket booking etc
So it is never something you can just ignore
This of this way
Ahmed and Daniel are editing the same notebook.
The notebook says:
Score = 10 but Ahamed changes it to "Score = 20"
Meanwhile Daniel had already copied the old value which is "Score = 10"
Then Daniel writes:
Score = 15
Which now made Ahmed update effectively disappeared.
Lost Update is a common form of race condition where a program A changes the value but Program B later writes its own version of the value, effectively overwriting A's change.
