Java Notes
Thread Questions
Name _______________________________
- Which areas of memory do separate threads share?
Circle all that are correct.
- Call stack
- Heap
- Static memory
- They don't share any memory.
- If cooperative multithreading is used,
which of the following causes a thread to give up
use of the CPU?
Circle all that are correct.
- Expiration of its time-slice.
- Blocking by an IO request.
- A call to yield().
- Call to a synchronized method which is being executed by another thread.
- Call to a unsynchronized method which is being executed by another thread.
- Which are correct statements about processes / tasks and threads?
Circle all that are correct.
- Processes share the same virtual memory; threads do not.
- The communication cost is lower between threads than between processes.
- Multiple processes can only be run on CPUs with mulitple CPUs, but threads can be run even if there is one CPU.
- When you run several programs in your system (eg, a word processor, a browser, etc), they are started as separate threads (not processes).
- Which are true statements about calling a GUI listener
(eg, on a JButton).
Circle all that are correct.
- Java starts a separate thread for each listener.
- Long calculations which are performed by a listener will block the GUI from responding to user actions.
- The user should start a separate thread for long CPU-intensive listener calculations.
- There is no need to create a separate thread for a long listener calculation if the calculation performs operations that frequently allow other threads to use the CPU.
- Which classes can be used to create new threads?
Circle all that are correct.
- Any class which is a subclass of Thread.
- Any class which implements the Runnable interface.
- Every class because every object has its own monitor.
- In which situations are threads used or should be considered?
Assume there is only one CPU on the machine the programming is running on.
Circle all that are correct.
- CPU intensive operations which can be computed in parallel may be run on separate threads to improve performance.
- Multiple IO operations (eg, loading data from several network sources) can be performed in parallel by using separate threads to reduce the total wait time.
- Operations that require a timer.
- Long GUI calculations.
- Using large, slow (eg, O(N)), data structures.















