1.3Kпросмотров
23.5%от подписчиков
8 марта 2026 г.
questionScore: 1.4K
👩💻 Викторина: что выведет код? public class Main { private static ThreadLocal<String> threadLocal = new ThreadLocal<>(); private static InheritableThreadLocal<String> inheritable = new InheritableThreadLocal<>(); public static void main(String[] args) { threadLocal.set("main"); inheritable.set("main"); Thread child = new Thread(() -> { System.out.print(threadLocal.get() + " "); System.out.print(inheritable.get() + " "); inheritable.set("child"); Thread grandChild = new Thread(() -> { System.out.print(inheritable.get()); }); grandChild.start(); try { grandChild.join(); } catch (Exception e) {} }); child.start(); }
} ➡️ Easy Java | #Викторина