Anki Deck Changes

Commit: 82414821 - pprog

Author: lhorva <lhorva@student.ethz.ch>

Date: 2026-02-24T23:57:26+01:00

Changes: 8 note(s) changed (4 added, 4 modified, 0 deleted)

ℹ️ Cosmetic Changes Hidden: 1 note(s) had formatting-only changes and are not shown below

Note 1: ETH::2. Semester::PProg

Deck: ETH::2. Semester::PProg
Note Type: Horvath Classic
GUID: E%{Xlt1YG0
added

Previous

Note did not exist

New Note

Front

ETH::2._Semester::PProg::03._Java_Threads::4._Joining_Threads
What's the alternative to busy waiting for all worker-threads to terminate?

Back

ETH::2._Semester::PProg::03._Java_Threads::4._Joining_Threads
What's the alternative to busy waiting for all worker-threads to terminate?

Using thread.join();

Performance trade-off:
  • Join (sleep, wakeup) typically incurs context switch overhead
  • If worker threads are short-lived, busy waiting may perform better
  • Later in the course: SpinLock
Field-by-field Comparison
Field Before After
Front What's the alternative to busy waiting for all worker-threads to terminate?
Back Using thread.join();<br><br>Performance trade-off:<br><ul><li>Join (sleep, wakeup) typically incurs context switch overhead</li><li>If worker threads are short-lived, busy waiting may perform better</li><li>Later in the course: SpinLock</li></ul>
Tags: ETH::2._Semester::PProg::03._Java_Threads::4._Joining_Threads

Note 2: ETH::2. Semester::PProg

Deck: ETH::2. Semester::PProg
Note Type: Horvath Cloze
GUID: L;tWm+I&15
modified

Before

Front

ETH::2._Semester::PProg::Terminology
A bad interleaving is an interleaving that yields a problematic or otherwise undesirable computation. E.g. an incorrect result, a deadlock or non-deterministic output.

Back

ETH::2._Semester::PProg::Terminology
A bad interleaving is an interleaving that yields a problematic or otherwise undesirable computation. E.g. an incorrect result, a deadlock or non-deterministic output.

After

Front

ETH::2._Semester::PProg::03._Java_Threads ETH::2._Semester::PProg::Terminology
A bad interleaving is an interleaving that yields a problematic or otherwise undesirable computation

Back

ETH::2._Semester::PProg::03._Java_Threads ETH::2._Semester::PProg::Terminology
A bad interleaving is an interleaving that yields a problematic or otherwise undesirable computation

E.g. an incorrect result, a deadlock or non-deterministic output.
Field-by-field Comparison
Field Before After
Text A {{c1::bad interleaving}} is an interleaving that yields {{c2::a problematic or otherwise undesirable computation}}. E.g. {{c3::an incorrect result, a deadlock or non-deterministic output}}. A {{c1::bad interleaving}} is {{c2::an interleaving that yields a problematic or otherwise undesirable computation}}.&nbsp;
Extra E.g. an incorrect result, a deadlock or non-deterministic output.
Tags: ETH::2._Semester::PProg::Terminology ETH::2._Semester::PProg::03._Java_Threads

Note 3: ETH::2. Semester::PProg

Deck: ETH::2. Semester::PProg
Note Type: Horvath Classic
GUID: N=-BFf&KQi
added

Previous

Note did not exist

New Note

Front

ETH::2._Semester::PProg::03._Java_Threads::4._Joining_Threads
What if a worker thread throws an exception?

Back

ETH::2._Semester::PProg::03._Java_Threads::4._Joining_Threads
What if a worker thread throws an exception?

  • Exception is (usually) shown on console
  • Behaviour of thread.join() is unaffected
  • \(\Rightarrow\) Main thread may not be aware of an exception inside a worker thread
Field-by-field Comparison
Field Before After
Front What if a worker thread throws an exception?
Back <ul><li>Exception is (usually) shown on console</li><li>Behaviour of thread.join() is unaffected</li><li>\(\Rightarrow\)&nbsp;Main thread may not be aware of an exception inside a worker thread</li></ul>
Tags: ETH::2._Semester::PProg::03._Java_Threads::4._Joining_Threads

Note 4: ETH::2. Semester::PProg

Deck: ETH::2. Semester::PProg
Note Type: Horvath Cloze
GUID: OQfr*wOjfT
modified

Before

Front

ETH::2._Semester::PProg::Terminology
A thread starves if it can never enter a/any critical section.

Back

ETH::2._Semester::PProg::Terminology
A thread starves if it can never enter a/any critical section.

After

Front

ETH::2._Semester::PProg::03._Java_Threads ETH::2._Semester::PProg::Terminology
A thread starves if it can never enter a/any critical section.

Back

ETH::2._Semester::PProg::03._Java_Threads ETH::2._Semester::PProg::Terminology
A thread starves if it can never enter a/any critical section.
Field-by-field Comparison
Field Before After
Text A thread {{c1::starves}} if it can {{c2::never enter a/any critical section}}. A thread {{c1::starves}} if {{c2::it can never enter a/any critical section}}.
Tags: ETH::2._Semester::PProg::Terminology ETH::2._Semester::PProg::03._Java_Threads

Note 5: ETH::2. Semester::PProg

Deck: ETH::2. Semester::PProg
Note Type: Horvath Cloze
GUID: d%A(hxXDuk
added

Previous

Note did not exist

New Note

Front

ETH::2._Semester::PProg::03._Java_Threads
The execution order is non-deterministic.

Back

ETH::2._Semester::PProg::03._Java_Threads
The execution order is non-deterministic.
Field-by-field Comparison
Field Before After
Text The execution order is {{c1::non-deterministic}}.
Tags: ETH::2._Semester::PProg::03._Java_Threads

Note 6: ETH::2. Semester::PProg

Deck: ETH::2. Semester::PProg
Note Type: Horvath Cloze
GUID: mqvz~z;n#[
added

Previous

Note did not exist

New Note

Front

ETH::2._Semester::PProg::03._Java_Threads::3._Java_Threads
Threads can have a priority between 1 and 10:

Back

ETH::2._Semester::PProg::03._Java_Threads::3._Java_Threads
Threads can have a priority between 1 and 10:

JVM uses the priority of threads to select the one that uses the CPU at each moment.

t.setPriority(Thread.MAX_PRIORITY); // updates the thread's priority
Field-by-field Comparison
Field Before After
Text Threads can have a priority between {{c1::1}} and {{c1::10}}:
Extra JVM uses the priority of threads to select the one that uses the CPU at each moment.<br><br>t.setPriority(Thread.MAX_PRIORITY); // updates the thread's priority
Tags: ETH::2._Semester::PProg::03._Java_Threads::3._Java_Threads

Note 7: ETH::2. Semester::PProg

Deck: ETH::2. Semester::PProg
Note Type: Horvath Cloze
GUID: pO7Qm0Zc[}
modified

Before

Front

ETH::2._Semester::PProg::Terminology
Busy waiting occurs when a thread busily (actively) waits, e.g. by spinning in a loop, for a condition to become true. 

Back

ETH::2._Semester::PProg::Terminology
Busy waiting occurs when a thread busily (actively) waits, e.g. by spinning in a loop, for a condition to become true. 

In the opposite scenario, the thread sleeps (i.e. is blocked) until the condition becomes true. 

After

Front

ETH::2._Semester::PProg::03._Java_Threads ETH::2._Semester::PProg::Terminology
Busy waiting occurs when a thread busily (actively) waits.

Back

ETH::2._Semester::PProg::03._Java_Threads ETH::2._Semester::PProg::Terminology
Busy waiting occurs when a thread busily (actively) waits.

E.g. by spinning in a loop, for a condition to become true. 

In the opposite scenario, the thread sleeps (i.e. is blocked) until the condition becomes true. 
Field-by-field Comparison
Field Before After
Text {{c1::Busy waiting}} occurs when a thread {{c2::busily (actively) waits}}, e.g. by spinning in a loop, for a condition to become true.&nbsp; {{c1::Busy waiting}} occurs when {{c2::a thread busily (actively) waits}}.
Extra In the opposite scenario, the thread sleeps (i.e. is blocked) until the condition becomes true.&nbsp; E.g. by spinning in a loop, for a condition to become true.&nbsp;<br><br>In the opposite scenario, the thread sleeps (i.e. is blocked) until the condition becomes true.&nbsp;
Tags: ETH::2._Semester::PProg::Terminology ETH::2._Semester::PProg::03._Java_Threads
↑ Top