java - placing functions executed by multiple threads into a Queue -


i creating library simulator within java. library has multiple borrowers threads. each borrower thread performs list of functions e.g.(create borrow list,borrow books library, return books library). array of borrowers created within model class,and each thread started within loop. having issue regards having functions run borrowers put in type of output queue, whereby first function entered first borrower run etc.

my question is, there way to, instead of executing each function when each borrower thread gets it, put functions threads output queue work through?

i fixed similar problem using blockingdeque(link, first in, first out). consumer thread pops first task deque , processes it. once finished reports , takes next task , on. other threads - in case borrowers - put task deque in last position.

hope helps!


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -