i have 100 threads , want make sure @ time max 3 threads run in sequence created.
i.e.
i have numbers 1 100. want print below
thread1 thread2 thread3 ' ' ' but @ time 3 threads allowed. once of thread 1,2,3 completed. next thread in sequence should start.
i know can using semaphoreslim interested know answer mutex or other way.
suppose have application can server maximum 3 requests @ time. 100 requests , want server them in fifo order maximum 3 @ time. hope clears doubt,
to have maximum of 3 threads running @ same time, pool of threads of size 3 should used. should implement thread pool pattern queues execution requests in fifo queue , have maximum limit of 3 requests executing @ same time.
the thread pool guarantee requests start execution in same order since uses fifo queue. however, not guarantee finish execution in same order.
Comments
Post a Comment