Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Thread-Safety in Go - An Overlooked Concern

Preslav Mihaylov
April 24, 2021
340

Thread-Safety in Go - An Overlooked Concern

A talk on learning the fundamentals of thread-safety in Go as presented on The Go Conference, Japan (https://gocon.jp/)

Materials - http://bit.ly/goconjp-thread-safety

Preslav Mihaylov

April 24, 2021
Tweet

Transcript

  1. Thread-Safety in Go An Overlooked Concern P. Mihaylov Software Engineer,

    Tech. Trainer, Speaker [email protected] Go Conference Tokyo 2021, A random zoom room on the Internet
  2. What’s covered 1. What does “thread-safety” mean? 2. Should you

    care about it at all? 3. Thread-safety problems & solutions a. When is there a potential thread-safety issue? b. Atomic access to shared state c. Delegating thread-safety d. Atomic compound actions e. Visibility & stale data 4. Where to go from here?
  3. “I don’t need thread-safe classes as I’m typically writing web

    apps without spawning any threads…” the average web dev
  4. Non-shared state Stack #1 Thread #1 Non-shared state #1 Non-shared

    state #2 Shared memory aka heap Shared state Non-shared state Stack #2 Thread #2
  5. 0

  6. 1

  7. 2

  8. 3

  9. What’s not covered 1. Initialisation safety & Immutable objects 2.

    Thread-confinement 3. Concurrency tooling - atomic variables/collections, synchronizers 4. Goroutine Management 5. Channels 6. Managing goroutine lifecycle via cancellation/interrupts 7. Dealing with performance/liveness issues (i.e. deadlock, livelock, etc.) 8. The Go Memory Model
  10. Thread-Safety in Go An Overlooked Concern P. Mihaylov Software Engineer,

    Tech. Trainer, Speaker [email protected] Go Conference Tokyo 2021, A random zoom room on the Internet