Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to synchronize before reading the attibutes of a marker ?
How to synchronize before reading the attibutes of a marker ? [message #846721] Mon, 16 April 2012 09:27
Kristof Szabados is currently offline Kristof Szabados
Messages: 69
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
Previous Topic:linked resource question
Next Topic:Reusing Eclipse Icons
Goto Forum:
  


Current Time: Tue Sep 02 00:36:28 EDT 2014

Powered by FUDForum. Page generated in 0.11542 seconds