Splitting and merging threads