fixed reader and writer. Fixed mutex problem.