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

Sven Barth pascaldragon at googlemail.com
Sat May 31 12:38:50 CEST 2014


On 31.05.2014 12:10, fredvs wrote:
>>> The question here is: where did you type it?
> Inside the loop in thread, after each queue()... and also just before end of
> thread.

*That* does not help. Queue put's the method pointer you provide into a 
queue that needs to be read by the *main thread*. It *will* fail if you 
use it from within a different thread especially the one which calls 
Queue (much worse with Synchronize, because Synchronize will *block* 
until CheckSynchronize was called).

>>> the next thing to go for, is probably be to try to get this
>>> `CheckSynchronize;` integrated into java in a decent manner
>>> (applicable to most use cases, that is). Good luck with that :-)
>
> Yep, but using a java-timer is not the best way to use the library.
> One of the great feature of uos-unit (for fpc users), is all the
> queue(procedure) at begin of thread, begin/end of the loop inside the thread
> and at end of the thread.
> But for the uos-library I could use a java-timer who do a
> "fpc-checksynchronize()" at x interval, but it is not perfect because it
> will always loose the x interval for synchronization...

There's no way around it. The only way to call CheckSynchronize is to 
call it from the main thread and that main thread is the one which 
invokes loading the library on the Java side. So the way you currently 
do it *is* the way.

Regards,
Sven




More information about the fpc-pascal mailing list