[fpc-pascal] Java crash when fpc library CallVoidMethod in a thread.

Ewald ewald at yellowcouch.org
Fri May 30 11:38:49 CEST 2014


On 30 May 2014, at 10:46, fredvs wrote:

> re-@ Ewald :
> 
>>> It *must* be called in the context of the main thread (the thread that
>>> loaded the library)
> 
> OOps, so do you mean that CheckSynchronize must be called by Java ?
> So i have to add a "custom" procedure in the fpc library (who will be only a
> fpc CheckSynchronize()) ?
> 
> Is it that that you mean, calling CheckSynchronize from the main Java class
> (not from the main thread of the library) ?
> 


Have you got an event/main loop?

If you have something like
	While true do
	Begin
		... code ...
	End;

Simply append CheckSynchronize at the end of this block:
	While true do
	Begin
		... code ...

		CheckSynchronize;
	End;

If you have an eventloop, but you haven't got access to the actual code of the loop, you should look for mechanisms that hook up to this loop (something like http://wiki.freepascal.org/Main_Loop_Hooks ?); how this can be done in java, I do not know. You could even try using a timer to accomplish this (it is far from ideal, but you can experiment further then ;-) ), as long as it is a timer that doesn't execute it's events in it's own different thread (if applicable).

As you can see, I am rather vague on the subject, because (1) I am not a java programmer and (2) I don't know enough of your architecture to make any specific comment.

--
Ewald




More information about the fpc-pascal mailing list