多线程之常见问题

死锁产生条件

  1. Mutual Exclusion: Only one process can access a resource at a given time. Or, more accurately, there is limited access to a resource. A deadlock could also occur if a resource has limited quantity.
  2. Hold and wait: Processes already holding a resource can request additional resources, without relinquishing their current resources
  3. No preemption: One process cannot forcibly remove another process' resource
  4. Circular wait: Two or more processes form a circular chain where each process is waiting on another resource in the chain

Questions:

Thread vs. Process

Difference between thread and process

Context Switch

How would you measure the time spent in a context switch?

Dining Philosophers

Deadlock-Free Class

扩展阅读

ping pong测试

你可能感兴趣的:(多线程之常见问题)