The code using value_avail doesn't solve the critical section problem in general. For one thing, the code doesn't work for more than two threads. (What if there were two printing threads?)
The code doesn't even solve the critical section problem for two threads.