added write function in thread_controller.php