C++ Pthreads Programs for synchronization problems and solutions