From: Kim C. L. <lim...@gm...> - 2005-06-10 16:15:33
|
Hi Kevin, Sorry for my stupid question. I have rewrite the test program.=20 The following is my test program. ################################################## package require Thread package require Ttrace set tid_0 [thread::create -preserved] ttrace::eval { proc foo {} { puts foo } proc bar {} { puts bar } } set func_1 { =09foo } thread::send -async $tid_0 $func_1 ########################################## Error: ~~~~~ $ tclsh wiki.tcl Error from thread tid0x41454bb0 can't find package Ttrace while executing "package require Ttrace" Error from thread tid0x41454bb0 invalid command name "foo" while executing "foo" =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D May i know how come the created thread is not able to execute the function = foo? Can i have a short/simple example how to use ttrace? Best Regards, Kim Chuan. On 6/10/05, Kevin Kenny <ke...@cr...> wrote: >=20 > lim...@gm... said: > > package require Thread > > package require Ttrace > > for {set i 0} {$i < 4} {incr i} { > > set tid($i) [thread::create -preserved] > > bar > > } > > ttrace::eval { > > proc foo {} { > > puts foo > > } > > proc bar {} { > > puts bar > > } > > } >=20 > Your problem is not with Ttrace, but with understanding Tcl at a > much more fundamental level. Tcl is not a compiled language - it > evaluates the commands in its scripts in the order in which they > appear. >=20 > In your case, you are creating threads and calling [bar] in the > [for] loop at the head of the script, before you have defined > the [bar] procedure (in the ttrace::eval}. > -- > 73 de ke9tv/2, Kevin KENNY GE Corporate Research & Development > ke...@cr... P. O. Box 8, Bldg. K-1, Rm. 5B36A > Schenectady, New York 12301-0008 USA >=20 > |