1) Your pseudocode does not use semaphores, so it is not a solution.
2) This does not match how primitive mutex / wait / notify Java works.
3) This probably won't work. Since you release the mutex before acquiring a condition, there is a chance of a race condition. (It is not entirely clear that this is so because the semantics of your "primitives" are open to interpretation.)
. , javadocs Semaphore, , .