|How to synchronize before reading the attibutes of a marker ? [message #846721]
||Mon, 16 April 2012 09:27
| Kristof Szabados
Registered: July 2009
I have a very strange issue with handling markers.
What I do:
In one thread I create markers on several files in a project.
In an other thread I collect all markers from all resources, and try
to check their attributes /* testing if the result is fine */.
for this I use "project.findMarkers(type, true,
IResource.DEPTH_INFINITE);" to collect the markers.
And I use "o1.getAttributes();" to get the attributes of a marker in
The first thread is run inside a "WorkspaceJob".
And the second thread uses "job.join();" to wait for the first to finish.
If I just run it like this it:
- might finish fine.
- might report that there is no marker on one of the files.
- the getAttributes might throw an exception .. for a marker
collected with findmarkers.
If I add a "Thread.sleep(5000);" right after the join() call ... all
of the markers are found, and I always get the attributes.
I realize that this is a synchronization issue ... but actually I can
not find any information on what and how I should synchronize the second
thread to, so that it only starts once the creation of the markers is
finished and they can be safely retrieved.
Does anyone have any information that could help me further ?
Powered by FUDForum
. Page generated in 0.11542 seconds