handle thread locks