Unisex Bathroom problem without semaphore
System.out.println(sex + " using bathroom. Current employees in bathroom = " + size);


This line is not protected by lock, so it is possible that size can change before the output is generated.

For example, if two 'M' arrive simultaneously, you could get as output:

M using bathroom.  Current employees in bathroom = 2
M using bathroom.  Current employees in bathroom = 2


which omits outputting ... = 1.



inUseBy is left as the last occupant, even when size decreases to 0.  In the constructor, it is initialized to "", implying that the empty string might also indicate the bathroom is available to any gender.  When you decrease size to zero, you should clear inUseBy.