How to synchronize before reading the attibutes of a marker ? [message #846721] |
Mon, 16 April 2012 13:27 |
Kristof Szabados Messages: 82 Registered: July 2009 |
Member |
|
|
Hi,
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
an iterator.
The first thread is run inside a "WorkspaceJob".
And the second thread uses "job.join();" to wait for the first to finish.
The problem:
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 ?
Best Regards
Kristof
|
|
|
Powered by
FUDForum. Page generated in 0.03404 seconds