What is the difference between thread safe and thread compatible?

mkUltra :

What is the difference between thread safe and thread compatible?

  • What thread compatible mean?
  • What is use cases for thread compatible?

UPD: I have found this definition in the grpc documentation of StreamObserver.

Also, I have found the link to Characterizing thread safety but its still not clear for me.

If a method requires to be in synchronize block, that means that is just threaded unsafe?

Peter Wishart :

Thread safe means that an object can be used by many threads concurrently and still be correct 1

Thread hostile means that the object does something (mutates static state, thread local storage etc.) that prevents it from being thread safe.

Thread compatible means not thread safe, but not thread hostile - so to satisfy thread safety, the user must perform synchronization themselves


1 But the definition of correctness varies a little...

Java In Theory And In Practice defines this according to the class's specification.

Geoff Romer at Google and Wikipedia define this as simply lack of data races.

I usually hope this to mean no crashes, deadlocks or other surprises.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=80532&siteId=1