Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference of "concurrent" and "thread-safe" in Java 7 API documentation?

I just read through the API documentation of the java.util.concurrent package.

My impression is that "concurrent" and "thread-safe" are used synonymously there.

Example:

ConcurrentLinkedDeque - An unbounded concurrent deque based on linked nodes. ConcurrentLinkedQueue - An unbounded thread-safe queue based on linked nodes.

In the scope of the concurrency package can I assume that the wording thread-safe and concurrent mean the same thing?

like image 809
zsawyer Avatar asked Oct 29 '25 16:10

zsawyer


2 Answers

Yes ... everything in the concurrent package can be used concurrently from different threads; e.g. thread-safe.

Specifically on the page you link to, under the "Concurrent Collections" section:

A concurrent collection is thread-safe, but not governed by a single exclusion lock.

Aside from that ... the entire purpose of the java.util.concurrent.* packages is to provide tools for concurrent (multi-threaded) programming.

See: Oracle's Java tutorials; Concurrency

like image 166
Brian Roach Avatar answered Nov 01 '25 05:11

Brian Roach


I think in this context it means "a thread-safe collection that, being non-blocking (unlike other older collection such as Stack that use synchronization), are better suited for concurrent access".

like image 25
LexLythius Avatar answered Nov 01 '25 07:11

LexLythius



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!