I hope this helps . First, you create a Semaphore with 10 initial permits, as explained here. It is not an upper limit, so release() can make the number of available permits go above 10. Also, look at the code below:
should help you out The clang error is because ThreadAdd is declared as void * and doesn't return anything. Just return 0. One issue is that sem_wait and sem_post can fail. In that case, they return -1 and you need to check errno for the cause. Your code looked okay to me so I tried it on two machines: - SE Linux, worked just fine - Mac, sem_wait failed.
hop of those help? It's possible that "doesn't work as expected" means your expectations are wrong. Of note, there are some problems with the linked code, which I assume you used verbatim. The SendMessage function is mapped twice. The first mapping is correct, but never used:
LRESULT SendMessageA(HWND paramHWND, int paramInt, WPARAM paramWPARAM,
LRESULT SendMessageA(HWND paramHWND, int paramInt, int paramInt2,
IllegalMonitorException using Semaphore and Monitor in Java