Package 

Class PreemptChannelSupport


  • 
    public abstract class PreemptChannelSupport
    
                        

    The preemptive channel concurrency pattern, there are two channels: preemptive channel and normal channel

    TODO: compare with ReadWriteLock

    • both channel allows multiple threads

    • new workers have to wait until there is no ready freeze nor running freezer

    • a freezer locks the working channel immediately, but have to wait to run util all workers are finished

      |------ waiting ------------|- ready -|-------------- critical -------------------|---finished----

                                The entrance gate                                    The exit gate

    Preemptive channel: ------------#1--#1--#1------|----#2---|-----------------------------------#3-------|--- #4 -------- | | | Normal channel: ----*1----*1--*1------*1----|---------|-----------*2--*2------*2--*2---------------|--- *3 --------

    #1 The waiting preemptive tasks #2 The ready preemptive tasks #3 The running preemptive tasks #4 The finished preemptive tasks

    *1 The waiting workers *2 The running workers *3 The finished workers