Multithreading Flashcards
What are the four types of CPU architecture?
SISD, SIMD, MISD, MIMD
What are the parallel programming sub models of MIMD
Single program multiple data, SPMD and Multiple program multiple Data MPMD
Types of memory architecture
Shared and distributed
What are the types of shared memory architecture?
UMA, uniform memory access meaning that all CPUs access the memory at equal speed.
NUMA nonuniform memory access
What is symmetric multiprocessing or SMP
Is a type of UMA. Has two or more identical processors connected to a single shared memory thru a system bus.
What is cache coherency
cache coherence is the uniformity of shared resource data that ends up stored in multiple local caches
Four states of a thread in general?
- new state() - thread created but no CPU resources.
- Runnable state() - Thread is ready to be executed or is waiting for other states.
- blocked state () - thread is blocked from execution because of some operations to complete, like timers. Does not take cpu at this stage
- terminated stat ()- is when a thread finishes operation or is stopped.
What is the join method in threads()
The join() method in Java is provided by the java.lang.Thread class that permits one thread to wait until the other thread to finish its execution.
InterruptedException
Thrown when a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted, either before or during the activity.
Difference between Thread and Runnable in Java?
Best option (P2I)
Thread is a class. It is used to create a thread
Runnable is a functional interface which is used to create a thread
Thread has multiple methods including start() and run()
Runnable has only abstract method run
Each thread creates a unique object and gets associated with it
Runnable - Multiple threads share the same objects.
Multiple Inheritance is not allowed in java hence after a class extends Thread class, it can not extend any other class but If a class is implementing the runnable interface then your class can extend another class.
What are the Six states of a Thread in Java
- new
- runnable
- Blocked
- Waiting
- timed_waiting
6 Terminated
What is the garbage collector
It’s automatic memory management that runs in the background and attempts to reclaim memory no longer in use by the program.
Its a daemon thread.
What is mutex or mutual exclusion?
it ensures that only one thread can execute the critical section of a computer program at a time.
What is Race condition?
Race condition in Java occurs in a multi-threaded environment when more than one thread try to access a shared resource, critical section of a program, (modify, write) at the same time.
What is a critical section in a program?
the part of the program which accesses the shared resource is known as the critical section.