Thread safety

In multi-threaded computer programming, a function is thread-safe when it can be invoked or accessed concurrently by multiple threads without causing unexpected behavior, race conditions, or data corruption.[1][2] As in the multi-threaded context where a program executes several threads simultaneously in a shared address space and each of those threads has access to every other thread's memory, thread-safe functions need to ensure that all those threads behave properly and fulfill their design specifications without unintended interaction.[3]

There are various strategies for making thread-safe data structures.[3]

  1. ^ Kerrisk, Michael (2010). The Linux Programing Interface. No Starch Press. p. 699, "Chapter 31: THREADS: THREAD SAFETY AND PER-THREAD STORAGE"{{cite book}}: CS1 maint: postscript (link)
  2. ^ Cite error: The named reference :1 was invoked but never defined (see the help page).
  3. ^ a b Oracle (November 2020). "Multithreaded Programming Guide: Chapter 7 Safe and Unsafe Interfaces". Docs Oracle. Retrieved 2024-04-30; "Thread Safety"{{cite web}}: CS1 maint: postscript (link)