INFO3136 EXAM Flashcards
(91 cards)
What is a process?
The entire program
What is a thread?
Small part of a process
What is process based multi-tasking controlled by?
OS (Kernel)
What is thread based multi-tasking controlled by?
JVM
Each thread gets its own what? (2)
- Call Stack
- Program counter
What happens if a thread cannot complete its task in the allotted time?
The thread is suspended
What happens when a thread is suspended?
State data is stored in CPU cache memory until text turn
What are the 2 ways to create threads in Java?
- Implement Runnable interface
- Extend Thread class
What method is in the Runnable interface?
run()
Why should you never call the run() method?
Method is automatically invoked by JVM. If you call it explicitly then a new thread is never made
What method is used to signal to the JVM that a thread is ready?
start()
What method is used to give up a thread’s remaining time?
yield()
What method is used to temporarily stop a thread?
sleep(long milliseconds)
What kind of exception can the sleep() method throw?
InterruptedException
What is the normal priority of a thread?
5
What kind of scheduling involves threads of equal priorities?
round-robin scheduling
What is it called when a low-priority thread never gets to run due to higher priority threads?
thread contention or thread starvation
What is the concurrency problem encountered in the 70’s called?
Lost Update Scenario
What were created to fix concurrency issues?
Transaction Rules
What is an example of a synchronized data structure in Java?
Vector
What kind of data structure is an ArrayList when considering threads?
Unsynchronized
Which is faster, a synchronized data structure or an unsynchronized?
Unsynchronized
What is it called when an unsynchronized program component allows data corruption?
Race Condition
What is it called when a class or data structure does not allow data corruption?
Thread-safe