Rearrange thread_t.
Modify arguments of palloc and pfree.