Java for Beginner
715 subscribers
659 photos
174 videos
12 files
1.03K links
Канал от новичков для новичков!
Изучайте Java вместе с нами!
Здесь мы обмениваемся опытом и постоянно изучаем что-то новое!

Наш YouTube канал - https://www.youtube.com/@Java_Beginner-Dev

Наш канал на RUTube - https://rutube.ru/channel/37896292/
Download Telegram
Что выведет код?

public class Task240725 {
private static synchronized void print(String msg) {
System.out.print(msg + " ");
}

public static void main(String[] args) {
Thread t1 = new Thread(() -> print("Hello"));
Thread t2 = new Thread(() -> print("World"));

t1.start();
t2.run();

try {
t1.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}


#Tasks
👍2
Что выведет код?

import java.util.concurrent.locks.ReentrantLock;

public class Task250725 {
public static void main(String[] args) {
ReentrantLock lock = new ReentrantLock();
try {
lock.lock();
System.out.println("First lock");
lock.lock();
System.out.println("Second lock");
} finally {
lock.unlock();
}
}
}


#Tasks
👍1