|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
Problems with multiple threads and GUI refresh in Java
I try to outsource just a little longer lasting function in its own thread (so far tried on Thread, Runnable or Swing workers) to keep the surface during the process to use. The function runs smoothly in the background, now I got the problem that at the end of the run () method, the surface should be redrawn (refresh ()), in order to represent the result of the background function, and since I get so far always an exception: org.eclipse.swt.SWTException: Invalid thread access Browsing the Internet I have found some evidence that there may be problems if one tries to change a background thread from the surface or update. Unfortunately, none of it (usually works only sparingly) above alternatives or not matched the rest of the program. I read somewhere that one of the surface suggest a refresh can, which will then (eventually) run from the actual surface thread, but unfortunately was not described how to do it. Now I hope this maybe someone has an idea how this problem could be solved. Please help me to resolve this problem. ![]() |
#2
| |||
| |||
Re: Problems with multiple threads and GUI refresh in Java
Here time is a code snippet: Code: setSearching (true); RunSearch = new Runnable Runnable () ( @ Override public void run () ( Entry current = langugeFileManager . GetEntryForKey (getCurrentKey ()); setSearching (false); viewer.refresh (); ) ); |
#3
| |||
| |||
Re: Problems with multiple threads and GUI refresh in Java
The Eclipse code book says, "You need the (SWT) Display instance, fire up the runnable asynchronously there. Code: RunSearch = new Runnable Runnable () ( ... ); display.asyncExec (runSearch); |
#4
| |||
| |||
Re: Problems with multiple threads and GUI refresh in Java
It is really the Eclipse objects. Some of these are only by the thread calling problems, which she has created. Since my thread so only after the application accessing it at some point, the access could not be allowed. The solution is relatively simple. I just have the line Event Queue. InvokeLater (runSearch);against the line Display.getCurrent (). AsyncExec (runSearch);been replaced and the thing runs like it should. The display (org.eclipse.swt.widgets.Display) seems to be the only way to access the objects and asynchronously. |
![]() |
|
Tags: eclipse, gui, internet, ioexception, java, multiple thread, swing |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Threads in Java | Addis | Guides & Tutorials | 4 | 18-02-2010 12:47 PM |
threads concept in java | vijji191 | Software Development | 2 | 30-11-2009 03:44 PM |
Multiple Inheritance in Java | KALINDA | Software Development | 3 | 03-11-2009 07:43 PM |
How to refresh data of Jtable in java | sarmad_iu | Software Development | 1 | 28-05-2009 02:45 PM |
Refresh Java Applet | Brake Fail | Software Development | 6 | 16-03-2009 10:02 PM |