How to Write a Multi-Threaded Java Code with MOBITEK Q24 STK API

SUMMARY OF SUPPORT for MOBITEK Q24 STK MODEM



 

Product:
  1.  MOBITEK Q24 STK MODEM HUB
  2. MOBITEK STK API version 6.3

Which programming language are you using?

  • JAVA
  • JRE version: 7.0-b147
  • JACOB versio: 1.14.3

OS

Windows 7, 64 it
SIM CARD: M-PESA
Description of Problem: We are unable to start multiple modems at once. We have written our application using JAVA, and we are using threads for each modem. The first one works fine, but the next ones fail to connect. The application complain about access.
Final Solution: We do no have Java programme in our team. We will try our best to assist you by pointing you to the right direction.The recommended way is to create an executable (.exe) for each STK modem. E.g. 8 STK modems will have 8 exe. This is easiest and safest. Threading requires programmer having good understanding of thread coding.
The “MobitekSTK6.dll” is apartment threaded. Refer to http://danadler.com/jacob/JacobThreading.html
“If you are using a component that declares itself as ThreadingModel “Apartment” (you can find this out by looking in the registry under its CLSID), and you plan to create, use and destroy this component in one thread – then you are following the rules of an STA and you can declare the thread as an STA thread.”We suggest that you code according to single threaded apartment (STA) instead of multi-threaded apartment (MTA). This means:-

  • all threads must be independent of other each other
  • thread 1 cannot call or pass values to thread 2

Please refer to
ScriptTest.java – creates an STA for the ScriptControl component and runs all its method calls from that STA.”

More Information