Reputation: 9506
I have a pool of smartcards reader and I can use them to compute a digital signature. This smartcard take a while to sign, so I need to setup a pool to queue requests and handle them as soon as possibile.
This is how I use a single smartcards:
try{
Smartcard smartcard=new Smartcard(slot); //slot: reader number
smartcard.sign(file);
}catch(SmartcardException e){
throw e; //unusable smartcard
}
I thought to use ExcecutorService to manage multiple smartcards using a pool size equals to smartcard readers. My doubt is if with this object I can attach a single reader to each thread, and moreover, if it can stop a single thread in case its smartcard fails with an SmartcardException (example: smartcard removed or broken).
I resume:
Is ExcecutorService suitable?
Upvotes: 0
Views: 112
Reputation: 40256
The ExecutorService backs the submission with a BlockingQueue
. These queues are obviously FIFO and so by default the thread pool will execute as soon as possible for each request.
Upvotes: 1