CMSC 132: Threads(100% Correct answers)
Multithreading Problems correct answers We want computer systems to be able to perform many tasks simultaneously How do we do this? Multiprocessing- Multiple processing units allow a system to actually work on several tasks in parallel Multitasking- OS managed Concurrent programming correct answers Both multiprocessing and multitasking involve independent, concurrently executing tasks Tasks may be executed in parallel on multiprocessor hardware A process correct answers A process is a program loaded into memory and executing Has its own independent address space Each process may be executing a different program Processes communicate via the operating system, files, and the network A thread correct answers Lightweight process, sequentially executed sequence of instructions inside a process Threads share address space with other threads in same process Each thread has its own local variables Multiple threads in a process execute the same program About multithreading correct answers One that's written to contain multiple threads that execute concurrently 1. Better utilize hardware resources 2. Capture the logical structure of a problem Creating threads in Java correct answers Extend the Thread class 1. Create a class extending Thread 2. Put the processing to be performed by thread objects in the class' run method 3. Create instances of this class 4. Call start on each object Implement the Runnable interface (the preferred approach) 1. Create a class implementing the Runnable interface 2. Put the processing to be performed by the thread objects in the class' run method
Document information
- Uploaded on
- May 29, 2024
- Number of pages
- 4
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers