Community
Participate
Working Groups
Build Identifier: 3.5.2 I have a table view which is periodically refreshed by a timer task: UICallBack.activate("refresher"); TimerTask timerTask = new TimerTask() { List<Object> result = null; public void run() { result = refreshInputFromDb(); table.getTableViewer().getControl().getDisplay().syncExec( new Runnable() { public void run() { updateTable(result); } }); } } } Timer timer = new Timer(); timer.schedule(timerTask, 20000, 20000); By doubleclicking on a table entry i stop the timer task and open an editor for editing the selected object. public void stopRefreshTimer() { timerTask.cancel(); timer.cancel(); timer = null; timerTask = null; UICallBack.deactivate("refresher"); } When opening the editor, a ContainerCheckedTreeViewer is initialized and filled with data. Sometimes is an invalid thread exception throwed. I think StructuredViewer is not thread safe. Is it a bug or not? Reproducible: Always
Created attachment 183225 [details] Stack trace
Why do you think that StructuredViewer should be thread safe? All SWT widget methods must be called from the UIThread. This includes updating JFace viewers, since they manipulate the widget. You get this error because you seem to call StructuredViewer#refresh from a non-UI thread at some point. BTW why do you call Display#syncExec() instead of asyncExec()? I'd recommend using asyncExec unless you have a very good reason not to.
Ok, it's my mistake. I call now display#asyncExec(). But i don't call StructuredViewer#refresh from a non UI-Thread. TimerTask is the only point where i access StructuredViewer in the updateTable method.
Is the problem fixed by using display#asyncExec()?
No this problem is still not fixed. Any idea?
Could you provide a complete self-running snippet that demonstrate the issue?
Any update on the complete project/snippet to reproduce the issue?
it was a bug in my code. thank's
(In reply to comment #8) > it was a bug in my code. thank's Closed as INVALID in this case.