The module Thread::Semaphore is what you may be looking for!!
In reply to Re: Critical section FCFS by naren88 in thread Critical section FCFS by aj7700