Saturday 15 June 2013

multithreading - Couchbase Java getAndLock confusion -


I have two questions. I have a multithreaded Java application what happens when a thread gets call and lock on a key , And immediately after that there is another thread call and lock on the same key?

  1. Will the second thread lock automatically until the first thread is released? Or, will the function call return with blank CAS value? Or, will it throw an exception?

  2. If the first thread clears the key (the entire document), what will happen to another thread?

    P>

    It says that it will try to get the lock for three seconds and then return OperationTimeoutException . (As Mikvid tells) If a lock is already present, then it should be returned immediately and indicate that the key is present in the error message, but the documentation does not say which exception / error is there in this case.

    For the second question, if the first thread removes a key, then it should be returned as if that key has never existed; In this case null .

No comments:

Post a Comment