0

Read thread calls at(i) function and write thread calls push_back() function, I get the error "out of range", Why?

egraldlo
  • 183
  • 2
  • 11

1 Answers1

3

Calling any non-const member function on any standard library object is not thread-safe (unless a particular non-const function is documented otherwise). You need to synchronise access to the object to prevent data races and thus Undefined Behaviour.

Angew is no longer proud of SO
  • 167,307
  • 17
  • 350
  • 455