P
P
pthon2019-12-18 07:35:17
Java
pthon, 2019-12-18 07:35:17

How to implement the work of two cycles at the same time?

Hello, how to implement the work of two infinite loops at the same time?
For example, here:

int i = 0;
        int c = 1;
        int a = 0;
        int b = 1;
        while (i < c) {
            System.out.println("1");
        }
        while (a < b) {
            System.out.println("2");
        }

Only 1 is displayed, how to make them work at the same time?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
aarifkhamdi, 2019-12-18
@pthon

Run them in two threads

D
Dmitry Shitskov, 2019-12-18
@Zarom

Merge into one with two conditions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question