Вот код.
Код: Выделить всё
public class Multithreading implements Runnable {
private static volatile Integer count = 1;
private static volatile String threadId = "1";
Object object = new Object();
@Override
public void run() {
try {
while (count
Подробнее здесь: [url]https://stackoverflow.com/questions/73720312/java-2-threads-printing-numbers-in-sequence[/url]