[fpc-pascal] Java crash when fpc library CallVoidMethod in a thread.
Ewald
ewald at yellowcouch.org
Sat May 31 13:50:42 CEST 2014
On 05/31/2014 12:38 PM, Sven Barth wrote:
> 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).
Couldn't have said it better ;-)
>>>> 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.
Indeed, but it is not `itegrated` into the main loop (if there is one?),
the way I understand it is that he currently calls CheckSynchronize
manually. This is of course a good way to test things, and it is the way
to go if you're writing your own main loop; but I think most users don't
write their own main loop (save for embedded developers, people writing
GUI toolkits and the like).
The ideal thing would be to find some java mechanism that allows him to
`append` this checksynchronize to `the` main loop, some main-loop hook
of sorts. That is IMHO the way to go for, but as my knowledge of java is
rather limited, I cannot comment on the feasibility or practical details
of this approach.
--
Ewald
More information about the fpc-pascal
mailing list