Add threads and barriers to pipeline