api:documentation:threads:start
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende Überarbeitung | |||
api:documentation:threads:start [2025/03/05 10:24] – [Monitorkonzept] martin | api:documentation:threads:start [2025/03/05 10:26] (aktuell) – [synchronized-Block] martin | ||
---|---|---|---|
Zeile 360: | Zeile 360: | ||
===== synchronized-Block ===== | ===== synchronized-Block ===== | ||
+ | < | ||
+ | |||
+ | <div class=" | ||
+ | |||
+ | <script type=" | ||
+ | |||
+ | Counter counter = new Counter(); | ||
+ | |||
+ | for (int i = 0; i < 3; i++) { | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | class Counter { | ||
+ | long counter = 0; | ||
+ | } | ||
+ | |||
+ | |||
+ | class Incrementer implements Runnable { | ||
+ | |||
+ | | ||
+ | long increment = 0; | ||
+ | int index; | ||
+ | |||
+ | | ||
+ | this.increment = increment; | ||
+ | this.counter = counter; | ||
+ | this.index = index; | ||
+ | } | ||
+ | |||
+ | | ||
+ | for (long i = 0; i < increment; i++) { | ||
+ | if(i % (increment/ | ||
+ | |||
+ | | ||
+ | long i = counter.counter; | ||
+ | i++; | ||
+ | counter.counter = i; | ||
+ | } | ||
+ | |||
+ | } | ||
+ | println(" | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
api/documentation/threads/start.txt · Zuletzt geändert: 2025/03/05 10:26 von martin