Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Thread safety
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Levels of thread safety== Different vendors use slightly different terminology for thread-safety,<ref>{{cite web|url=https://www.ibm.com/docs/en/i/7.5?topic=safety-api-thread-classifications |title=API thread safety classifications |publisher=IBM |date=2023-04-11 |access-date=2023-10-09}}</ref> but the most commonly used thread-safety terminology are:<ref name=":1">{{cite web |last=Oracle |date=2010-11-01 |title=Oracle: Thread safety |url=https://docs.oracle.com/cd/E37838_01/html/E61057/compat-14994.html#scrolltoc |access-date=2013-10-16 |publisher=Docs.oracle.com |postscript="A procedure is thread safe when the procedure is logically correct when executed simultaneously by several threads"; "3 level of thread-safe"}}</ref> *'''Not thread safe''': Data structures should not be accessed simultaneously by different threads. *'''Thread safe, serialization''': Uses '''a single mutex for all resources''' to guarantee the thread to be free of [[race condition#Computing|race conditions]] when those resources are accessed by multiple threads simultaneously. *'''Thread safe, MT-safe''': Uses '''a mutex for every single resource''' to guarantee the thread to be free of [[race condition#Computing|race conditions]] when those resources are accessed by multiple threads simultaneously. Thread safety guarantees usually also include design steps to prevent or limit the risk of different forms of [[deadlock (computer science)|deadlock]]s, as well as optimizations to maximize concurrent performance. However, deadlock-free guarantees cannot always be given, since deadlocks can be caused by [[callback (computer programming)|callbacks]] and violation of [[architectural layer]]ing independent of the library itself. [[Library (computing)|Software libraries]] can provide certain thread-safety guarantees.<ref>{{Cite web |title=MT Safety Levels for Libraries |url=https://docs.oracle.com/cd/E37838_01/html/E61057/compat-89113.html#scrolltoc |access-date=2024-05-17 |website=Docs Oracle}}</ref> For example, concurrent reads might be guaranteed to be thread-safe, but concurrent writes might not be. Whether a program using such a library is thread-safe depends on whether it uses the library in a manner consistent with those guarantees.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)