What if each thread were to put its pid into the array? Then the array would contain long streaks of one pid followed by long streaks of another pid. Does that give you any ideas?