[Cs3] do not combine back_inserter and parallel execution policy

Mikhail Nesterenko mnestere at kent.edu
Tue Apr 28 22:23:58 EDT 2026


CS3 students,

The example of parallel sort had generate_n() with back_inserter() and
parallel execution policy. back_inserter() uses push_back() which is not
thread safe since it updates the container. So it should not be used
in a parallel algorithm. Check this for more detailed explanation:

  https://stackoverflow.com/questions/66101548/is-it-safe-to-use-parallel-execution-policies-with-stdback-inserter

I updated the example code.

Thanks,
-- 
Mikhail


More information about the cs3 mailing list