malloc memory for thread