when should ou lock multithreading code example
Example: lock in multithreading
A Lock is a way/ method when appiled on a shared resource, informs the threads
whether it is in used currently by a thread, if it is in use,
it makes the threads to wait untill the thread which is using it releases the
lock.