Error writing data in a tree provided by a background thread

I'm trying to write a data read from a long running background thread in my component tree. I've tried to use runReadAction and runWriteAction methods to do it in the correct threads but it's not working. The runWriteAction is not running because even being executed in the writing thread the writing lock is false.

The method bellow is called internally by the runWriteAction method to check the correct writing state. Checking it debugging the code the isWriteThread() method is returning true but the myLock.isWriteLocked() method is returning false.

public boolean isWriteAccessAllowed() {
return isWriteThread() && myLock.isWriteLocked();
}

This is my code:

ApplicationManager.getApplication().executeOnPooledThread(() -> {
ApplicationManager.getApplication().runReadAction(() -> {
System.out.println("LOADING OBJECTS");
connectionLoadDispatcher.getMulticaster().onConnectionLoad(connection);
System.out.println("COMPLETED 1");
});

ApplicationManager.getApplication().invokeLaterOnWriteThread(() -> {
ApplicationManager.getApplication().runWriteAction(() -> {
System.out.println("RENDERING OBJECTS");
loadSObjects(connection, node);
System.out.println("COMPLETED 2");
});
}, ModalityState.NON_MODAL);
});


How can I do to get the write lock?

1 comment
Comment actions Permalink

Could you please show bigger context of what you're building here? com.intellij.openapi.application.Application#invokeLaterOnWriteThread(java.lang.Runnable) is Experimental API and must not be used by plugins. See also https://jetbrains.org/intellij/sdk/docs/basics/architectural_overview/general_threading_rules.html for summary.

0

Please sign in to leave a comment.