Add mutex to make SharedBuffer thread safe