Eclipse DemoCamp Bucharest<br />Deadlock Preventer - Test your java code for race conditions<br />TeodorMadan<br />CDT Com...
Agenda<br />Multitask Background <br />Lock contention example<br />Deadlock preventer<br />Automating<br />References.<br />
Making application multithreaded<br />Build<br />UI Main Thread<br />Indexing<br />Source Control<br />Search<br />
Making application multithreaded<br />UI Main Thread<br />Build<br />Search<br />> 27000 locks acquired at Eclipse SDK sta...
Deadlocks<br />Worker Thread 1<br />Lock A<br />B?<br />Worker Thread 2<br />Lock B<br />A?<br />
Removing followers<br />Worker Thread 1<br />Lock A<br />Lock B<br />Worker Thread 2<br />Lock B<br />Lock A<br />
Lock contention example<br />public synchronized void setProperty(Object newValue) { // A     value = newValue;     notify...
Lock contention example<br />public void setProperty(Object newValue) {     synchronized(this) {// A         value = newVa...
Lock contention example<br />public void setProperty(Object newValue) {     synchronized(this) {// A         value = newVa...
Deadlock preventer<br />Shortcut to launch application with lock monitor agent activated<br />Detects Inconsistent locking...
Deadlock preventer - Automation<br />Adding the Deadlock preventer is as simple as adding the following two arguments to t...
References<br />Author blog http://sergebeauchamp.blogspot.com/<br />GitHub https://github.com/sbeauchamp/Deadlock-Prevent...
Q & A<br />
Upcoming SlideShare
Loading in...5
×

DeadLock Preventer

1,332

Published on

Presentation at Indigo Eclipse DemoCamp Bucharest

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,332
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

DeadLock Preventer

  1. 1. Eclipse DemoCamp Bucharest<br />Deadlock Preventer - Test your java code for race conditions<br />TeodorMadan<br />CDT Commiter<br />June 2011<br />
  2. 2. Agenda<br />Multitask Background <br />Lock contention example<br />Deadlock preventer<br />Automating<br />References.<br />
  3. 3. Making application multithreaded<br />Build<br />UI Main Thread<br />Indexing<br />Source Control<br />Search<br />
  4. 4. Making application multithreaded<br />UI Main Thread<br />Build<br />Search<br />> 27000 locks acquired at Eclipse SDK start-up<br />Indexing<br />Source Control<br />
  5. 5. Deadlocks<br />Worker Thread 1<br />Lock A<br />B?<br />Worker Thread 2<br />Lock B<br />A?<br />
  6. 6. Removing followers<br />Worker Thread 1<br />Lock A<br />Lock B<br />Worker Thread 2<br />Lock B<br />Lock A<br />
  7. 7. Lock contention example<br />public synchronized void setProperty(Object newValue) { // A     value = newValue;     notifyPropertyChange(); }<br />private void notifyPropertyChange() {     synchronized(listeners) {// B         for (IListener listener : listeners)             listener.changed(); // C     } }<br />
  8. 8. Lock contention example<br />public void setProperty(Object newValue) {     synchronized(this) {// A         value = newValue;     }     notifyPropertyChange(); } <br />private void notifyPropertyChange() {     synchronized(listeners) {// B         for (IListener listener : listeners)             listener.changed(); // C     } }<br />
  9. 9. Lock contention example<br />public void setProperty(Object newValue) {     synchronized(this) {// A         value = newValue;     }     notifyPropertyChange(); } <br />private void notifyPropertyChange() {     IListener[] tmp;     synchronized(listeners) {// B         tmp = listeners.clone();     }     for (IListener listener : tmp)         listener.changed(); // C }<br />
  10. 10. Deadlock preventer<br />Shortcut to launch application with lock monitor agent activated<br />Detects Inconsistent locking order while acquiring locks between all threads in JVM<br />Extracts lock statistics for tuning lock contention<br />
  11. 11. Deadlock preventer - Automation<br />Adding the Deadlock preventer is as simple as adding the following two arguments to the “java” executable:<br />-javaagent:path-tocom.freescale.deadlockPreventer.wrapper_1.0.0com.freescale.deadlockpreventer.jar<br />-Xbootclasspath/a:path-tocom.freescale.deadlockPreventer.wrapper_1.0.0com.freescale.deadlockpreventer.jar;path-tojavassist.wrapper_1.0.0javassist.jar<br />By default just prints all inconsistent locks to console output.<br />There’s a server version listening for the deadlock preventer monitor events<br />
  12. 12. References<br />Author blog http://sergebeauchamp.blogspot.com/<br />GitHub https://github.com/sbeauchamp/Deadlock-Preventer<br />
  13. 13. Q & A<br />

×