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

fredvs fiens at hotmail.com
Fri May 30 13:08:41 CEST 2014


Yep, yep, yep some very good news...

1) Added a new procedure in fpc library:
 => 
procedure uos_checksynchro(PEnv: PJNIEnv; Obj: JObject) ; cdecl;
begin
checksynchronize();
end; 

2) And, of course, in fpc library exported as:
 =>
exports
...
uos_checksynchro name 'Java_uos_checksynchro', 
...

3) Added in Java wrapper class:
public static native void checksynchro();

4) In main Java application:
After that the fpc thread (who does a CallVoidMethod) was called by Java
(with  uos.play(0);):

=> uos.checksynchro();

5) And guess what... The CallVoidMethod is executed...

So, first conclusion : it is possible to synchronize a CallVoidMethod inside
a thread but Java main thread must call fpc-checksynchronize().

Hum, so maybe, (im new in Java) use a Java-timer who calls
uos.checksynchro(); at regular time...

1) @ Ewald => Oops i read just your answer now, i will study it...
2) @ Ewald => i prefer your solution (if i can do it work) because i prefer
not oblige Java-users to use a Java-timer.

PS : All other solutions are welcome...

PS2 : All those problems of synchronize CallVoidMethod inside a thread are
problems only for uos (audio library).
For fpGUI library, no any problems (because fpGUI library does not use
threads...), those Java developers have now the best widgetset for their
Java applications.

PS3 : Hum, if one day, i need a fptimer in a fpc library, is it possible to
use fptimer.ontimer who works with Java ?

Many thanks.

Fred.






-----
Many thanks ;-)
--
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Java-crash-when-fpc-library-CallVoidMethod-in-a-thread-tp5719098p5719447.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.



More information about the fpc-pascal mailing list