[Xotcl] XOTcl and Thread

Krzysztof Frukacz frukacz.krzysztof at gmail.com
Fri Feb 11 15:09:39 CET 2011


Hello everyone,

On 02/11/2011 08:37 AM, mail at xdobry.de wrote:
> I have run also into this problem (trap).
> Threads in Tcl are different than in Java or C#.
> The tcl threads are more like new independent processes (at Tcl level).
>

I have noticed that and I must say I really miss that Java/C type 
threads. I will now describe my problem more generally, maybe somebody 
will give me a hint on a good solution.

I have a class called Modem. It handles communication with a modem over 
serial port using AT commands. This class contains for example method 
sendSMS, that of course sends an SMS message :)
I also have other objects that gather data from different sources and 
they should report it over SMS. I would like to run those in separate 
threads.

In C/C++/Java I would do that:
1. create Modem object
2. start several threads for data processing objects
3. each data processing object will call [modem sendSMS +49123456789 
$reportText ]
For C++/Java every thread would get access to single object that handles 
communication (serial interface cannot be used by two objects at the 
same time). Of course Modem would implement some synchronization 
mechanisms like mutex (I find Java's ReentrantLock extremely useful).

I'll be grateful for your suggestions how to do it in XOTcl.

-- 
Krzysiek


More information about the Xotcl mailing list