C ++ 98 did not say anything about threads. Programs written in C ++ 98, but which use streams, do not have the value defined by C ++ 98. Of course, for stream extensions it is advisable to provide stable private local variables for streams, and they usually do this. But there may be threads for which this is not the case: for example, processes created by vfork on some Unix systems, as a result of which the parent and child will run on the same stack stack, since v in vfork means that there is no cloning of the address space, and vfork does not redirect the new process to another function.
C ++ 11 supports thread support. Local variables in separate activation chains in separate C ++ 11 threads do not interfere. But if you go beyond the limits of the language and throw out vfork or something similar to it, then all bets are disabled, as before.
But here is something. C ++ now has a closure. What if two threads simultaneously cause the same closure? Then you have two threads that use the same local variables. Closing is like an object, and its captured local variables are members. If two or more threads call the same closure, then you have a de facto multi-threaded object whose members (i.e., captured lexical variables) are shared.
A stream can also simply pass the address of its local variables to another stream, thereby causing them to be shared.
source share