Thread -Zähler -Synchronisationsproblem

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Thread -Zähler -Synchronisationsproblem

by Anonymous » 05 Mar 2025, 13:24

Ich versuche, Multithreading -Techniken zu lernen. < /strong>

Ich habe versucht, das synchronisierte Verhalten zu implementieren. in Thread T3. Ich erhalte jedes Mal unterschiedliche Werte, obwohl die erwartete Ausgabe 1000 betragen sollte. und wie man beide Zähler auf synchronisierte Weise inkrementiert.

Code: Select all

    public static void main(String args[]) throws InterruptedException {
AtomicIntegers atomicIntegers = new AtomicIntegers();
Thread t1= new Thread() {
@Override
public void run() {
for(int i =0; i

Top