running 3 threads in sequence java

前端 未结 10 620
天涯浪人
天涯浪人 2020-11-29 04:35

I have 3 threads 1st printing A 2nd printing B 3rd printing C

I want to print in sequence A B C A B C A B C and so on.....

So I wrote the program below, but

10条回答
  •  星月不相逢
    2020-11-29 05:22

    Replace:

    if(notifyAllExample.status!=1){
       notifyAllExample.wait();
    }
    

    with:

    while(notifyAllExample.status!=1){
       notifyAllExample.wait();
    }
    

    in all classes accordingly.

提交回复
热议问题