ELS61 - Accessing one Files in two Java Midlet concurrently | Telit Cinterion IoT Developer Community
September 11, 2017 - 5:46pm, 1625 views
I would like to access one file in two Java-Midlets and both should write to that file at different intervals. For this purpose its required to implement some thread synchronization or file locking mechanism such that there occurs no problem if both midlets want to write at the same time.
Is there a possibility to do that with the gemalto standard libraries?
I would recomend here to use the PipeConnection class to have communication between your two midlets, and use this comunication like flag to "allow" to write in the file.
In any case the file has to be close before the other midlet can open/write inside the file again. Maybe a nice implementation could be to send the info to a third midlet, using the PipeConnection, and use this Midlet only to write in the file
Just take a look in the documentation to:
pipe = (PipeConnection) Connector.open("pipe://*:" + name + ":1.0;");
Somewhere over the rainbow!!! Looking for the Oz Land!!!
Thanks for the hint! I will try that.
So there is no build in function in any connection class that locks a file or throws an IOException if the file is already opened by another Midlet?
There's no such thing. So you will need the solution suggested by Antonio.