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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.