Debugging In a Multi- Threads Program
Contents Advantages Of Multithreaded Programs Characteristics Of Sequential and Multithreaded Programs Why More Bugs And How to Prevent them How To Debug
1 Advantages Of Multithreaded Programs
Raise clock rate? “parallelism” ILP, Instruction Level Parallelism TLP, Thread Level Parallelism
2 Characteristics Of Sequential and Multithreaded Programs
Comparison
Sample Behavior is nondeterministic
3 Why More Bugs And How to Prevent them
Where Is Bug “ Out-Of-Order ”
Out-Of-Order sleep() Latch CyclicBarrier CountDownLatch latch = new CountDownLatch(3); countDown() await() CyclicBarrier cyclicBarrier = new CyclicBarrier(3); cyclicBarrier.await(); Producer-Consumer Mode wait() 、 notify() 、 notifyAll()
Where Is Bug Synchronization
Shared Memory Model Easy to understand Memory coherence is managed by the operating system
Synchronization synchronized Destroy parallelism
Where Is Bug Deadlock Other
4 How To Debug
1 breakpoint 2 3 logJPDA JDI ENTER TEXT