This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
[dev oct 9] I have one thread which holds a certain write mutex (module system) and waits for some task to finish. Another thread (with that task) calls mutex.postWriteRequest(Runnable) and immediately blocks, contrary to its docs: "If there is no writer & reader, it will be run immediately; otherwise it will be run later when the last writer and/or reader finishes." This causes a deadlock. Same for writeAccess, which is documented: "It may be run asynchronously." which is not in fact true, the code shows that it always blocks. Workaround: post to request processor and from there run synchronously in write mutex.
I see. The true is that postWriteRequest javadoc should mention that we are talking about one thread. If the writer is in different thread and there is no other writer/reader in my thread. It blocks. Running post write access in different thread (after all readers/writers exits) might be useful, but could be dangerous!? Or not? Anyway the javadoc should be probably made more precise & for future we introduce a new method (or boolean flag) to allow a postXRequest to be executed in any thread.
Right. I can see the current behaviors of these methods being useful in some circumstances. The point is that if you expect them to behave as documented, you can easily be disappointed (as in deadlock). Maybe just documentation needs to be corrected; or add nonblocking variants of these calls.
I updated the docs, so now it should be clear. Yarda told me to add methods that will allow completely asynchronous processing of posted requests, but this is planned for 3.4
Thanks, the docs look much better and the tests too... if you have a request for added methods, probably better to file them separately and mark this FIXED. Nobody ever gets REMINDED by IssueZilla.
Ok, I am opening this as an enh. for new methods for release 3.4 Please add methods post(Read|Write)Request (Runnable run, boolean anythread) that will allow to place a request into the mutex and run it without blocking the callers thread.
Set target milestone to TBD
In issue #32439's patch, readAccess(Runnable) and writeAccess(Runnable) do indeed run their runnables asynch (using a private dedicated request processor) in case they would other block for a writer or the last reader to exit.
Possibly could be considered an API change - behavior of *Access(Runnable) is a bit different.
Rather won't make changes to semantics of existing Mutex.