מרוץ ה-ThreadsThread Race
כמה threads רצים יחד. תמיד נכון, יכול לטעות, או יכול להיתקע? ואז מריצים 200 פעמים ובודקים.
Several threads run together. Always correct, can go wrong, or can get stuck? Then run it 200 times and see.
מרוץ ה-ThreadsThread Race
count++ בלי הגנה: נסו לאבד עדכוןcount++ unprotected: try to lose an update
count++ בלי הגנה: נסו לאבד עדכוןcount++ unprotected: try to lose an update
count++ בתוך synchronizedcount++ inside synchronized
AtomicInteger.incrementAndGetAtomicInteger.incrementAndGet
בלי volatile: דגל עצירה שלא נראהWithout volatile: a stop flag nobody sees
volatile: האם העובד רואה את השינוי?volatile: does the worker see the change?
wait ו-notify עם תנאי בלולאהwait and notify with a condition in a loop
wait בלי לבדוק תנאי: notify שהלך לאיבודwait without a condition: a lost notify
סדר מנעולים הפוך: deadlockOpposite lock order: deadlock
אותו סדר מנעולים: אין deadlockThe same lock order: no deadlock
בדיקה ואז פעולה: שניים לוקחים את העותק האחרוןCheck, then act: two people take the last copy
בדיקה ופעולה בתוך מנעולCheck and act inside a lock
BlockingQueue: יצרן וצרכןBlockingQueue: producer and consumer
מה קורה בתוך thread poolWhat happens inside a thread pool
כל הקוד במשחקים נלקח מהקורס ורץ באמת בזמן בניית האתר.All the code in the games comes from the course and really ran while the site was built.