How (not) to structure applications into threads