fix alloc in a thread bug