Bug 153398 Invalid thread access in Snippet133
Running SWT Snippet 133 (print text to printer) throws this exception: Exception in thread "Printing" org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:3374) at org.eclipse.swt.SWT.error(SWT.java:3297) at org.eclipse.swt.SWT.error(SWT.java:3268) at org.eclipse.swt.widgets.Widget.error(Widget.java:435) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:331) at org.eclipse.swt.widgets.Control.getFont(Control.java:939) at org.eclipse.swt.snippets.Snippet133.print(Snippet133.java:230) at org.eclipse.swt.snippets.Snippet133$7.run(Snippet133.java:204) It works if you patch the line: printingThread.start(); with this: display.syncExec(printingThread);
examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet133.java
File file = new File(name);
			FileInputStream stream= new FileInputStream(file.getPath());
			try {
				Reader in = new BufferedReader(new InputStreamReader(stream));
				char[] readBuffer= new char[2048];
				StringBuffer buffer= new StringBuffer((int) file.length());
				int n;
				while ((n = in.read(readBuffer)) > 0) {
					buffer.append(readBuffer, 0, n);
				}
				textString = buffer.toString();
				stream.close();
			} catch (IOException e) {
				MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
				box.setMessage("Error reading file:\n" + name);
				box.open();
				return;
			}
		} catch (FileNotFoundException e) {
			MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
			box.setMessage("File not found:\n" + name);
			box.open();
			return;
		}	
		text.setText(textString);
	}
	void menuFont() {
		FontDialog fontDialog = new FontDialog(shell);
		fontDialog.setFontList(text.getFont().getFontData());
		FontData fontData = fontDialog.open();