??????? ???? ??? ??? ??? ???? ??? ? ?? ???? ??? ?? ? ?? ?? ?? ?? ???? ?????. ?? ??? ??? ???? ???????. ???? ??? ?? ?????, ??? ???? ???? ???? ???, ?? ??? ??? ?? ??? ???? ?????.
??? ??? ???? ?????.
"???? ?? ???! ??? ? ???!" — ?? ?? ????? ??????.
"??? ?? ?? ??? ???!" - ????? ??? ??? ??????.
??? "???? ??? ?? ? ???? ??? ??? ??? ??? ?? ??? ? ? ????."?? ??????.
? ?? ??: ???
??? ????? ??? ??????. ?? ???? ??? ? ???? ?? ???? ???? ??? ????? ??? ?????.
"?? ? ?? ? ?? ???? ????? ?? ? ????"?? ??? ??????.
??? ?? ?????.
class SantaFactory { private final Queue<String> conveyorBelt = new LinkedList<>(); private final int MAX_CAPACITY = 10; public void produce(String toy) throws InterruptedException { synchronized (conveyorBelt) { while (conveyorBelt.size() == MAX_CAPACITY) { System.out.println("Производитель ждёт: лента заполнена!"); conveyorBelt.wait(); // Производитель ждёт, пока появится место } conveyorBelt.add(toy); System.out.println("Игрушка произведена: " + toy); conveyorBelt.notifyAll(); // Уведомляем упаковщиков о новой игрушке } } public void consume() throws InterruptedException { synchronized (conveyorBelt) { while (conveyorBelt.isEmpty()) { System.out.println("Потребитель ждёт: игрушек нет!"); conveyorBelt.wait(); // Упаковщик ждёт, пока появится игрушка } String toy = conveyorBelt.poll(); System.out.println("Игрушка упакована: " + toy); conveyorBelt.notifyAll(); // Уведомляем производителей о свободном месте } } }
wait ? informAll? ?? ??:
wait(): ??(?: ? ???)? false? ? ??? ???? ?? ??? ???.
informAll(): ?? ?? ?? ???? ?? ??? ? ??? ?????.
? ?? ??: BlockingQueue
??? ???? ?? informAll ??? ????? ?? ?? ??? ????? ??? ??????. ?? ?? ?? ????? ???? ???? ??? ??? BlockingQueue? ??????.
BlockingQueue? ??? ?????.
???? ? ?? ????? ???? ?????.
???? ?? ??? ????? ???? ??? ?? ??? ?????.
class SantaFactory { private final Queue<String> conveyorBelt = new LinkedList<>(); private final int MAX_CAPACITY = 10; public void produce(String toy) throws InterruptedException { synchronized (conveyorBelt) { while (conveyorBelt.size() == MAX_CAPACITY) { System.out.println("Производитель ждёт: лента заполнена!"); conveyorBelt.wait(); // Производитель ждёт, пока появится место } conveyorBelt.add(toy); System.out.println("Игрушка произведена: " + toy); conveyorBelt.notifyAll(); // Уведомляем упаковщиков о новой игрушке } } public void consume() throws InterruptedException { synchronized (conveyorBelt) { while (conveyorBelt.isEmpty()) { System.out.println("Потребитель ждёт: игрушек нет!"); conveyorBelt.wait(); // Упаковщик ждёт, пока появится игрушка } String toy = conveyorBelt.poll(); System.out.println("Игрушка упакована: " + toy); conveyorBelt.notifyAll(); // Уведомляем производителей о свободном месте } } }
? ?? ??: ???? ??? ?
???? ??? ??? ??? ??? ??? ??? ??????. ?? ? ??? ??? ??? ????? ? ?? ???? ???????.
“???? ? ?? ?? ??? ?? ?? ?? ???? ??? ????.” ??? ??????.
?? ?:
import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; class SantaFactoryBlocking { private final BlockingQueue<String> conveyorBelt = new ArrayBlockingQueue<>(10); public void produce(String toy) throws InterruptedException { conveyorBelt.put(toy); // Если лента заполнена, поток автоматически ждёт System.out.println("Игрушка произведена: " + toy); } public void consume() throws InterruptedException { String toy = conveyorBelt.take(); // Если лента пуста, поток автоматически ждёт System.out.println("Игрушка упакована: " + toy); } }
???? ?? ??:
newFixedThreadPool(n): ???? n?? ??? ?? ?????.
submit(task): ??? ? ???? ??? ?????.
shutdown(): ?? ??? ??? ? ??? ?????.
? ?? ??: CompletableFuture
??? ???? ??? ??? ??? ??????. ?? ???? ?????? ???? ???? ??? ??????.
import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class SantaRaceWithExecutors { public static void main(String[] args) { SantaFactoryBlocking factory = new SantaFactoryBlocking(); ExecutorService executor = Executors.newFixedThreadPool(4); // 4 эльфа // Запускаем 2 производителя for (int i = 1; i <= 2; i++) { executor.submit(() -> { try { for (int j = 1; j <= 20; j++) { factory.produce("Игрушка #" + j); Thread.sleep(100); // Производство занимает время } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }); } // Запускаем 2 упаковщика for (int i = 1; i <= 2; i++) { executor.submit(() -> { try { for (int j = 1; j <= 20; j++) { factory.consume(); Thread.sleep(150); // Упаковка занимает время } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }); } executor.shutdown(); // Завершаем работу после выполнения всех задач } }
CompletableFuture? ?? ??:
???: ??? ?? ???? ???? ?? ????? ????? ?????.
?? ???: ???? ???? ??? ??? ????.
??? ???????!
??? ???? ?? ???? ??? ??? ??? ?????. "?? ???, ?? ??? ?? ?????. ?????? ??? ??? ? ??? ???? ?? ??? ? ???? ??????!"
??? ?? ?? ?? ??? ??? ?? ????? ?????? ??? ??? ????? ?? ??? ?????.
? ?? ? ?? ???? ???! ?
? ??? ??? ?? ??: Java ?????? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??











?? ?? ?? ??? ??? ?? ??? ??, ? ? ?? ? ??? ?????. 1. ??? ?? ???? ?? ???? ???-????, ? ??? ??? ??? ? ????, Hashmap? ???-??? ?? ??? ??? ???? ????. 2. NULL ? ?? ???? HashMap? ??? NULL ?? ?? ? ?? ???? ?? HashTable? NULL ?? ?? ???? ??? NullPointerException? ?????. 3. ????? ??? ????? ?? ??? ?? ?? ? ????? HashTable? ? ??? ?? ?? ??? ????. ?? ConcurrenTashMap? ???? ?? ????.

Java? ?? ??? ??? ?? ??? ??? ?? ??? ??? ?? ??? ?? ?? ??? ???? ??? ?? ???? ?????. 1. ??? ???? ??? ?? ?? ? ???? ?? ??? ???? ?? ?? ??? ? ????. 2. ???? ?? ??? ???? ??? ?? ???? ?? ?? ??? ???????. 3. ?? ???? ?? ?? ?? ? ???? ???? ?? NULL ?? ??? ? ????. 4. ?? ???? ??? ?? ?? ? ??? ?????? ?? ??? ??? ?? ?? ??? ????? ??? ??? ??? ??????? ?? ???? ??????.

staticmethodsininterfaceswereIntRectionSelffacesswithinteffaceswithinteffaceswithintintinjava8toallowutilityFunctionswithinterfaceitswithinteffaceswithinterfaceffaces

JIT ????? ??? ???, ??? ?? ? ???, ?? ?? ? ???? ? ? ?? ?? ??? ? ?? ??? ?? ??? ??????. 1. ??? ???? ?? ?? ??? ??? ?? ?? ???? ??? ?? ?????. 2. ??? ?? ? ??? ?? ?? ? ??? ???? ?? ?? ???; 3. ?? ??? ??? ?? ??? ???? ???? ???? ? ?? ?? ??? ?????. 4. ?? ??? ?? ??? ??? ???? ???? ?? ? ??? ???? ?? ??? ?????.

???? ??? ??? Java?? ??? ?? ???? ??? ?? ? ? ??? ??? ???? ? ?????. ?? ???? ??? ??, ??? ?? ??? ?? ?? ??? ??? ????? ???? ????? ?????. ?? ??? ??? ??, ????? ? ??? ????, ?? ??? ??? ?????? ? ?? ? ?? ?????.

??? ??? ?? ?? ??? ????? ? ???? ????? ???? ?? ???? ?? ???? ?????. ?? ??? ??? ????. ?? ?? ?? ??? ???? ???? ?? ?? ??? ??? ?? ?? ??? ??? ?????. ?? ??? ??? ????. ?? ??? ?? ??? ?? ?? ??? ?? ?? ??? ???? NewClass ()? ??? ?? ???? ????. ?? ??? ?? ??? ???? ?? ??? ?? ? ? ??? ?? ?? ??? ????? ????? ?????. ?? ??, ?? ?????? ?????, ??? ? ?? ????? ??? ?? ?????. ???? ?? ?? ??? ???? ?? ???? ?? ? ??? ???? ?? ??? ?? ?????? ?????. ???? ???? ??? ??, ?? ?? ? ?? ??? ????, ?? ?? ???? ?????.

injava, thefinalkeywordpreventsavariable'svalue'svalueffrombeingchangedafterassignment, butitsbehaviordiffersforprimitivesandobjectreences.forprimitivevariables, asinfinalintmax_speed = 100; wherereassoncesanerror.forobjectref

??? ? ?? ??? ???? : ????? ?? ?. 1. int? ???? ???? ?? ?? ?? ? ??? ???? ?????. 2. ?? ? ???? (int) myDouble ??? ?? ?? ??? ?????. ?? ??? ??? ?? ??? ?? ??, ?? ?? ?? ???? ?? ??? ?? ???? ?? ?????. ???? ? ??? ??? ????. ?? ??? ??? ??? ??? ??? ?? ??? ??? ? ??? ?? ???? ??? ??? ??? ??? ? ??? ?? ??? ?? ??? ?? ?? ? ? ????. ?? ?? ??? ?? ??? ??? ??? ??? ? ??????.
