Chapter 23 Flashcards
Can a process have multiple threads
Yes
What is light weight and what is heavy weight, Thread or process
Processes are heavy weight
Thread is light weight
how thread and process deal with address base
Thread shared address base and process have own address base
Does java have built-in support for threading
Yes
Who deals with threads of java on OS level
Virtual Machine (VM)
What is starvation
One thread executes and keep executing and another thread can not run. It is called starvation.
What are 2 approaches in JAVA to create threads
1- Interface based
2- Inheritance based
Can we set priority in JAVA threads
Yes
How can we change priority of threads
Using 3 predefined constants - Thread.MAX_PRIORITY (typically 10) - Thread.NORM_PRIORITY (typically 5) - Thread.MIN_PRIORITY (typically 1) Or set to 1-10
What is the method to set priority
setPriority(int priority)
What is the exception for threads
IllegalArgumentException
Does cooperative multi threading old
Yes
What are 2 ways to avoid starvation
- Sleep
- Yield