Add mutex to thread