Add thread_mutex reference counting