change tw
use small lock in pthread hook