Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the Trove library thread-safe?

Is the GNU trove library thread-safe? I am particularly interested in TObjectDoubleHashMap. I looked at their documentation, but it hasn't mentioned anything, so shall we assume it is not thread-safe?

like image 536
Ravi Avatar asked Oct 24 '11 11:10

Ravi


2 Answers

It has utilities to make it thread safe. See: http://trove4j.sourceforge.net/javadocs/gnu/trove/TCollections.html

Also, since the collections are mostly backed by primitive arrays, you can (usually) safely perform read operations (iteration/get) across multiple threads.

like image 70
J. Dimeo Avatar answered Sep 21 '22 14:09

J. Dimeo


Its not thread safe. You can use synchronized or your own Lock to make it thread safe.

like image 35
Peter Lawrey Avatar answered Sep 19 '22 14:09

Peter Lawrey