Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which scala collection is best for constructing a resource pool

I'd like to create a shared resource pool which could be accessed by multiple thread concurrently.

Each thread will do something like:

  1. fetch a resource from the pool (if no resource available, do something else)

  2. do something with the fetched resource

  3. return the resource back to the pool.

In java, probably I will go with ConcurrentLinkedQueue.

Is there any better option in scala?

like image 393
anuni Avatar asked Nov 11 '22 02:11

anuni


1 Answers

Scala runs on Java so you could just continue using a ConcurrentLinkedQueue. If it works for you, why mess with it?

like image 190
Ryan Avatar answered Nov 14 '22 21:11

Ryan