Skip to main content

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 13:27
Kristof Szabados is currently offline Kristof SzabadosFriend
Messages: 79
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
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
Previous Topic:linked resource question
Next Topic:Reusing Eclipse Icons
Goto Forum:

Current Time: Tue Sep 25 09:17:09 GMT 2018

Powered by FUDForum. Page generated in 0.01563 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top