thread allocation