Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
~Java   ~        @hakurai
stopRequested    Java        HotSpot
while(!stopRequested){   if(!stopRequested){  i++;                       while(true){}                              i++;  ...
while(!stopRequested){   if(!stopRequested){  i++;                       while(true){}                              i++;  ...
Javasynchronizedvolatile
synchronized               synchronizedsynchronized
private final Object lock = new Object();private List<String> list;public void add(String text){  synchronized (lock){     ...
private final Object lock = new Object();private List<String> list;public void add(String text){  synchronized (lock){     ...
private final Object lock = new Object();private List<String> list;public void add(String text){  synchronized (lock){     ...
private final Object lock = new Object();private List<String> list;public String get(int index){  synchronized (lock){     ...
private final Object lock = new Object();private List<String> list;public String get(int index){  synchronized (lock){     ...
private final Object lock = new Object();private List<String> list;public void add(String text){  synchronized (lock){     ...
private final Object lock = new Object();   private List<String> list;   public void add(String text){     synchronized (lo...
private final Object lock = new Object();   private List<String> list;   public void add(String text){     synchronized (lo...
//   Java
1                  2                  3Java   null   (   )
!1       2   N
1   2   N
T
(atomic)
from   to
from   to
1
1
1
2
2
2
3
3
3
4
4
4
1
2
2
2
3V               T       A    P            V       T        B                Q
3P   Q
3(1)P       Q       P(2)Q(3)Q(4)P
1
2L       T   LV       T    V
private final Object lock = new Object();private List<String> list;private String get(int index){   synchronized (lock){   ...
private final Object lock = new Object();private List<String> list;private String get(int index){   synchronized (lock){   ...
volatile   volatile
volatile                   1   V           T   V       T   V           T       V           T
volatile                   2   V           T       V           T   V           T   V       T
volatile           volatile
volatile                                                 3 volatile                                 (reordering)  private ...
volatile                                                 3 volatile                                 (reordering)  private ...
volatile           Java
T
JavaJavaEffective Java
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
Upcoming SlideShare
Loading in …5
×

並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~

2,424 views

Published on

Published in: Technology, News & Politics
  • I have done a couple of papers through ⇒⇒⇒WRITE-MY-PAPER.net ⇐⇐⇐ they have always been great! They are always in touch with you to let you know the status of paper and always meet the deadline!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Best dissertation help you can get, thank god a friend suggested me ⇒⇒⇒WRITE-MY-PAPER.net ⇐⇐⇐ otherwise I could have never completed my dissertation on time.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Best dissertation help you can get, thank god a friend suggested me ⇒⇒⇒WRITE-MY-PAPER.net ⇐⇐⇐ otherwise I could have never completed my dissertation on time.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Was a little hesitant about using ⇒⇒⇒WRITE-MY-PAPER.net ⇐⇐⇐ at first, but am very happy that I did. The writer was able to write my paper by the deadline and it was very well written. So guys don’t hesitate to use it.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • I have done a couple of papers through ⇒⇒⇒WRITE-MY-PAPER.net ⇐⇐⇐ they have always been great! They are always in touch with you to let you know the status of paper and always meet the deadline!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~

  1. 1. ~Java ~ @hakurai
  2. 2. stopRequested Java HotSpot
  3. 3. while(!stopRequested){ if(!stopRequested){ i++; while(true){} i++; } }
  4. 4. while(!stopRequested){ if(!stopRequested){ i++; while(true){} i++; } }
  5. 5. Javasynchronizedvolatile
  6. 6. synchronized synchronizedsynchronized
  7. 7. private final Object lock = new Object();private List<String> list;public void add(String text){ synchronized (lock){ listadd(text); }}
  8. 8. private final Object lock = new Object();private List<String> list;public void add(String text){ synchronized (lock){ listadd(text); }}
  9. 9. private final Object lock = new Object();private List<String> list;public void add(String text){ synchronized (lock){ listadd(text); lock }}
  10. 10. private final Object lock = new Object();private List<String> list;public String get(int index){ synchronized (lock){ return list.get(index); }}
  11. 11. private final Object lock = new Object();private List<String> list;public String get(int index){ synchronized (lock){ return list.get(index); list }}
  12. 12. private final Object lock = new Object();private List<String> list;public void add(String text){ synchronized (lock){ list.add(text); }}public String get(int index){ return list.get(index);}
  13. 13. private final Object lock = new Object(); private List<String> list; public void add(String text){ synchronized (lock){ list.add(text); list } }IllegalArgumentException public String get(int index){ return list.get(index); }
  14. 14. private final Object lock = new Object(); private List<String> list; public void add(String text){ synchronized (lock){ list.add(text); list } }IllegalArgumentException public String get(int index){ return list.get(index); }
  15. 15. // Java
  16. 16. 1 2 3Java null ( )
  17. 17. !1 2 N
  18. 18. 1 2 N
  19. 19. T
  20. 20. (atomic)
  21. 21. from to
  22. 22. from to
  23. 23. 1
  24. 24. 1
  25. 25. 1
  26. 26. 2
  27. 27. 2
  28. 28. 2
  29. 29. 3
  30. 30. 3
  31. 31. 3
  32. 32. 4
  33. 33. 4
  34. 34. 4
  35. 35. 1
  36. 36. 2
  37. 37. 2
  38. 38. 2
  39. 39. 3V T A P V T B Q
  40. 40. 3P Q
  41. 41. 3(1)P Q P(2)Q(3)Q(4)P
  42. 42. 1
  43. 43. 2L T LV T V
  44. 44. private final Object lock = new Object();private List<String> list;private String get(int index){ synchronized (lock){ return list.get(index); }}
  45. 45. private final Object lock = new Object();private List<String> list;private String get(int index){ synchronized (lock){ return list.get(index); list }}
  46. 46. volatile volatile
  47. 47. volatile 1 V T V T V T V T
  48. 48. volatile 2 V T V T V T V T
  49. 49. volatile volatile
  50. 50. volatile 3 volatile (reordering) private int num = 0; private volatile boolean initialized; public void run(){ num = 100; initialized = true; }
  51. 51. volatile 3 volatile (reordering) private int num = 0; private volatile boolean initialized; public void run(){ num = 100; num initialized = true; }
  52. 52. volatile Java
  53. 53. T
  54. 54. JavaJavaEffective Java

×