Sunday 17 July 2022

About Docker

 





Advantages of Containers








Thursday 24 September 2020

Thread Priority and Difference between Yield & Join


Understanding thread priorities

Understanding the Thread priorities is next important step in learning Multi-threading and specially how yield() works.

1. Remember that all the threads carry normal priority when a priority is not specified.
2. Priorities can be specified from 1 to 10. 10 being the highest, 1 being the lowest priority and 5 being 
        the normal priority.
3. Remember that the thread with highest priority will be given preference in execution. But there is no 
        guarantee that it will be in running state the moment it starts.
4. Always the currently executing thread might have the higher priority when compared to the threads 
        in the pool who are waiting for their chance.
5. It is the thread scheduler which decides what thread should be executed.
6. t.setPriority() can be used to set the priorities for the threads.
7. Remember that the priorities should be set before the threads start method is invoked.
8. You can use the constants, MIN_PRIORITY,MAX_PRIORITY and NORM_PRIORITY for setting 
         priorities.

Difference between Yield() and Join() method

Yield


Purpose: Yield means currently executing thread gives chance to the threads that have equal priority in the Thread-pool. Yield does not guarantee that it will change the state of the currently executing thread to runnable state immediately.

State Change: It can only make a thread from Running State to Runnable State, not in wait or blocked state.

Join


Purpose: The join() method of a Thread instance can be used to “join” the start of a thread’s execution to the end of another thread’s execution so that a thread will not start running until another thread has ended. If join() is called on a Thread instance, the currently running thread will block until the Thread instance has finished executing.

State Change: If the method join() called on the Thread instance, a thread will not start running until another thread finish executing.