Updating swing components from an arbitrary thread

6854933580_2c8b688306_z

will postpone the event to the next cycle (loop) of the EDT and let the other events in the chain complete.

Notice that you shouldn’t use this normally since it includes an overhead and complicates application flow, however when you run into issues in event processing we suggest trying this to see if its the cause. It might fire “false positives” meaning it might detect a violation for perfectly legal code and it might miss some illegal calls.

Action presentation (name, icon, etc.) is handled in the event thread. Actual editor implementation: unknown model, beyond what is required by the API. Has some sort of read/write lock and complex rules for avoiding the event queue.

Usually intended to be thread-safe, using fine-grained locking. Code completion queries and updates seem to run asynchronously. Structural models of other file types (properties files, XML, etc.) probably use fine-grained locking, performing parses off the event thread. Uses a variety of different models according to what layers it is interacting with.

There is also an API document which attempts to define some of the Supposedly thread-safe, using complex fine-grained locking.

Event delivery is usually synchronous though there isolated modifications are supported (erroneously referred to as "atomic"). auto refresh or JAR modification detection) are asynchronous.

"Threading model" refers to the general system by which an application does things in parallel (or does not do things in parallel): managing threads (a core Java language feature), locks and synchronization, asynchronous tasks, scheduled tasks and timers, the GUI loop, etc.

(According to its CVS history, this class has been patched at least 14 times to solve threading-related problems.) Subsystems that appear to use threading heavily, based on the above summary, include many parts of the Net Beans core implementation; the Datasystems API; the VCS Core module; the Debugger module; parts of the Java and XML modules; etc.

So how much is threading used in Net Beans, anyway?

Running a simple command using a Perl script over all Java sources in the Net Beans trunk as of Jul 07 2003, you can see a list of all packages including how many lines of code the package contains (skipping comments, blank lines, package declarations, and imports), and how many of those lines explicitly use threading-related idioms (including common classes and methods in the Java platform as well as Net Beans threading utilities).

However, it is a valuable tool in the process of detecting hard to track bugs that are sometimes only reproducible on the devices (due to race condition behavior).

This works well normally but on the EDT it might be a problem, if one of the operations is slow it might slow the whole EDT (painting, event processing etc.).

There are circumstances where they are useful or necessary.

You must have an account to comment. Please register or login here!