java - Can ScheduledThreadPool be use to accept different type of threads? -


working on problem have 3 cash counters serving number of customers. every counter take 1 sec process 1 item apart third counter takes 2 sec process each item. (e.g. customer 5 items on counter 1 take 5 seconds complete), customer b 3 items on counter c take 6 seconds. every customer has different time of joining queue. used scheduledexecutorservice create number of threads equivalent cash counters.

scheduledexecutorservice scheduledexecutorservice =executors.newscheduledthreadpool(3); 

now runnable implementation checks number of items , runs loops accordingly.

i submitting number of task depending on number of customer.

scheduledexecutorservice.schedule(new runnable(),timetojoin, timeunit.seconds); 

how assign different priorities 3 threads created executor service. last counter(thread) takes 2 second process each item.

you have provide custom threadfactory executorservice. threadfactory allow create new threads suit needs.

scheduledthreadpoolexecutor(int corepoolsize, threadfactory threadfactory)

more info here, in doc.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -