Lock / Mutex to an 8th grader

Lock / Mutex to an 8th grader

This is a submission for DEV Computer Science Challenge v24.06.12: One Byte Explainer.

Explainer

Imagine you’re in an exam hall where only one student can go to the restroom at a time using a pass. When they return, the pass goes to the next student. Similarly, computers use locks to let only one app access a resource at a time while others wait.

Additional Context

I am planning to post 5 submissions explaining “Lock/Mutex” at 5 levels of difficulty. This is Difficulty 1.

An 8th grader probably hasn’t heard of the term “mutex.” An explanation that relates to something they have seen and explains how computers use a similar concept can be helpful.

For more about explaining the term in 5 Levels of difficulty, refer to the below post. It’s interesting!

Cheers🎉 ~ sauravshah31