Updating swing components from an arbitrary thread Hot online chat i norge
If Swing is not thread-safe than how do you update components from other thread? is an asynchronous call and doesn't wait for GUI to be updated.By the way, both of these method make sure that Swing GUI components are updated in EDT thread only.Further, there are thousands of eyes checking the package for flaws.Wherever possible, use them in preference to your own code.As much as possible, use packages to handle your thread interaction problems.The authors of these packages specialise in the arcane art.Also monitor some known well-behaved apps so you get an idea the sort of behaviour you should find.You will be surprised just how many threads are in there.
Couple of my reader ask question, what does it mean by Swing is not thread-safe and How does it affect coding in Swing GUI application?
Even trivial Java apps are designed to run on multi-CPU machines with execution streams running in parallel. Each thread, by default, gets one megabyte of virtual RAM ( used a hybrid of green and native which allows scalability to thousands of threads. Pretty well the rest of thread implementations are native.
You, as application programmer, have no way, in pure Java, to control which kind of threads are used.
You write little hunks of code conforming to an interface, then queue them up to be scheduled concurrently. is running, most of the time it should be idle, just waiting for the next event. ) in the console window, it will interrupt and tell you what all the threads were doing.
If the event thread is busy running application code something is amiss.