| Author |
org.eclipse.swt.SWTException: Invalid thread access
|
sanjaynkumar kumar
Greenhorn
Joined: Aug 06, 2006
Posts: 2
|
|
Running into this error...please help. Exception in thread "5" org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:2942) at org.eclipse.swt.SWT.error(SWT.java:2865) at org.eclipse.swt.SWT.error(SWT.java:2836) at org.eclipse.swt.widgets.Display.checkDisplay(Display.java:627) at org.eclipse.swt.widgets.Display.create(Display.java:688) at org.eclipse.swt.graphics.Device.<init>(Device.java:129) at org.eclipse.swt.widgets.Display.<init>(Display.java:388) at org.eclipse.swt.widgets.Display.<init>(Display.java:379) at santest.test(santest.java:13) at santest.run(santest.java:28) at java.lang.Thread.run(Thread.java:595) I tried to implement the solution provided in the SWT FAQ. Not sure I am doing it right.. I was able to reproduce the error using this simplified version of what I doing in my actual code import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; public class santest implements Runnable { private int countDown = 5; public String toString() { return "#" + Thread.currentThread().getName() + ": " + countDown; } public void test() { final Display display = new Display(); display.syncExec (new Runnable () { public void run () { GC gc = new GC(display); final org.eclipse.swt.graphics.Image image = new org.eclipse.swt.graphics.Image(display, display.getBounds()); gc.copyArea(image, 0, 0); gc.dispose(); } }); /* Take the screen shot */ } public void run() { while(true) { System.out.println(this); test(); if(--countDown == 0) return; } } public static void main(String[] args) { for(int i = 1; i <= 5; i++) new Thread(new santest(), "" + i).start(); // Output is like SimpleThread.java } }
|
 |
sanjaynkumar kumar
Greenhorn
Joined: Aug 06, 2006
Posts: 2
|
|
|
Any suggestion anyone.. i have posted the snippet of code earliar... let me know if you need more details
|
 |
 |
|
|
subject: org.eclipse.swt.SWTException: Invalid thread access
|
|
|