|
From: qwy on 20 Jun 2008 05:54 Hi is there any command in Tcl that makes the same effect as the synchronize command in Java? Thanks
From: Arjen Markus on 20 Jun 2008 06:15 On 20 jun, 11:54, qwy <charli...(a)gmail.com> wrote: > Hi > > is there any command in Tcl that makes the same effect as the > synchronize command in Java? > > Thanks I guess you want to use threads? Have a look at the thread package - http://wiki.tcl.tk/2770 for instance or the man page on threads in a recent enough Tcl distribution (I think it came with Tcl 8.4) Regards, Arjen
From: Donal K. Fellows on 20 Jun 2008 06:15 qwy wrote: > is there any command in Tcl that makes the same effect as the > synchronize command in Java? Tcl uses a different threading model to Java. Normally, you use code that runs in interpreters that are isolated from each other (except when listening for events/messages from elsewhere) and with data that is kept entirely within the thread. This means that there are no locks being held, and that makes Tcl code work very nicely on multi-core systems. When you do want shared data, you use a Thread Shared Variable (tsv, part of the Thread package) and then the tsv::lock command will do the equivalent of a Java synchronize. But mostly we don't use shared data; message passing scales up better. Donal.
From: Ron Fox on 20 Jun 2008 08:47 It is important to repeat to yourself many times when learning a new programming language.. this language is different than the ones I know... So I suggest for you the mantra: TCLINJ (Tcl Is Not Java). You need to be open to the Tcl way of doing things which may be fundamentally different than the Java way of doing things. I've found it to be a great mistake to learn a new programming language by trying to make a tight mapping between the capabilities of one language and another. That tends to blind me to the intent of the new language, and its idiomatic patterns. Just a thought, just a suggestion. RF qwy wrote: > Hi > > is there any command in Tcl that makes the same effect as the > synchronize command in Java? > > Thanks -- Ron Fox NSCL Michigan State University East Lansing, MI 48824-1321
From: qwy on 20 Jun 2008 09:16 On Jun 20, 2:47 pm, Ron Fox <f...(a)nscl.msu.edu> wrote: > It is important to repeat to yourself many times when learning a new > programming language.. this language is different than the ones I > know... So I suggest for you the mantra: > > TCLINJ (Tcl Is Not Java). > > You need to be open to the Tcl way of doing things which may be > fundamentally different than the Java way of doing things. > > I've found it to be a great mistake to learn a new programming > language by trying to make a tight mapping between the capabilities of > one language and another. That tends to blind me to the intent of the > new language, and its idiomatic patterns. > > Just a thought, > just a suggestion. > > RF > > qwy wrote: > > Hi > > > is there any command in Tcl that makes the same effect as the > > synchronize command in Java? > > > Thanks > > -- > Ron Fox > NSCL > Michigan State University > East Lansing, MI 48824-1321 I really wonder what make you write so much useless comment and take it for granted that I am learning (new to) TclTk. The keyword Java maybe disturb you, or am I supposed to mention another language name instead of Java? I just want to solve a synchronisation issue in a Tcl software. Unfortunately, your suggestion is totally useless for me. :-(
|
Next
|
Last
Pages: 1 2 Prev: http::get in web page hangs server Next: xml-transforming (with tdom?) |