Skip to content

Commit d03c8b4

Browse files
author
Matthew Sebolt
authored
Update thread-safety-in-the-cpp-standard-library.md
1 parent ffbc196 commit d03c8b4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/standard-library/thread-safety-in-the-cpp-standard-library.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ ms.assetid: 9351c8fb-4539-4728-b0e9-226e2ac4284b
77
---
88
# Thread Safety in the C++ Standard Library
99

10-
The following thread safety rules apply to all classes in the C++ Standard Library—this includes `shared_ptr`, as described below. Stronger guarantees are sometimes provided—for example, the standard iostream objects, as described below, and types specifically intended for multithreading, like those in [`<atomic>`](../standard-library/atomic.md).
10+
The following thread safety rules apply to all classes in the C++ Standard Library—this includes `shared_ptr`, as described below. Stronger guarantees are sometimes provided—for example, the standard iostream objects, as described below, and types intended for multithreading, like those in [`<atomic>`](../standard-library/atomic.md).
1111

1212
An object is thread-safe for reading from multiple threads. For example, given an object A, it is safe to read A from thread 1 and from thread 2 simultaneously.
1313

1414
If an object is being written to by one thread, then all reads and writes to that object on the same or other threads must be protected. For example, given an object A, if thread 1 is writing to A, then thread 2 must be prevented from reading from or writing to A.
1515

16-
It is safe to read and write to one instance of a type even if another thread is reading or writing to a different instance of the same type. For example, given objects A and B of the same type, it is safe when A is being written in thread 1 and B is being read in thread 2.
16+
It's safe to read and write to one instance of a type even if another thread is reading or writing to a different instance of the same type. For example, given objects A and B of the same type, it's safe when A is being written in thread 1 and B is being read in thread 2.
1717

1818
## shared_ptr
1919

2020
Multiple threads can simultaneously read and write different [`shared_ptr`](../standard-library/shared-ptr-class.md) objects, even when the objects are copies that share ownership.
2121

2222
## iostream
2323

24-
The standard iostream objects `cin`, `cout`, `cerr`, `clog`, `wcin`, `wcout`, `wcerr`, and `wclog` follow the same rules as the other classes, with this exception: it is safe to write to an object from multiple threads. For example, thread 1 can write to [`cout`](../standard-library/iostream.md#cout) at the same time as thread 2. However, this can cause the output from the two threads to be intermixed.
24+
The standard iostream objects `cin`, `cout`, `cerr`, `clog`, `wcin`, `wcout`, `wcerr`, and `wclog` follow the same rules as the other classes, with this exception: it's safe to write to an object from multiple threads. For example, thread 1 can write to [`cout`](../standard-library/iostream.md#cout) at the same time as thread 2. However, this can cause the output from the two threads to be intermixed.
2525

2626
> [!NOTE]
27-
> Reading from a stream buffer is not considered to be a read operation. Instead it is considered to be a write operation because the state of the class is changed.
27+
> Reading from a stream buffer is not considered to be a read operation. Instead it's considered to be a write operation because the state of the class is changed.
2828
2929
## See also
3030

0 commit comments

Comments
 (0)