fixed bug in locking OS. Did not cater for flexible reads
refactoring of random threads