Re: Reg - Multi thread execution



On Sep 18, 7:50 am, 2boopa...@xxxxxxxxx wrote:
Hi ,

We are trying to use multiple thread to execute procedures in
parallel.

Thread_sample.tcl does the below.
proc Proc1, Proc2, Proc3 are defined.
Created 3 threads
sending the proc name to each thread for execution.

Content of Thread_sample.tcl

package require Thread
proc Proc1 {} {
puts "This is from proc1"

}

proc Proc2 {} {
puts "This is from proc2"

}

proc Proc3 {} {
puts "This is from proc3"

}

set Thread1 [thread::create]
set Thread2 [thread::create]
set Thread3 [thread::create]

thread::send $Thread1 "Proc1"
thread::send $Thread2 "Proc2"
thread::send $Thread3 "Proc3"

Getting below error while execution

D:\>tclsh Thread_sample.tcl
invalid command name "Proc1"
    while executing
"Proc1"
    invoked from within
"thread::send $Thread1 "Proc1""
    (file "Thread_sample.tcl" line 20)

Kindly let us know what is the issue with the above code.

Thanks
P.Boopathi

In Tcl there's a separate interpreter per thread.
So when you say "proc ..." it only creates the proc for the current
interpreter+thread.
To instruct other threads to execute some code, you must send them all
the material before, just like building your villa on a desert island:

thread::send $thr {
proc foo
proc ...
set ::someglobal ...
...
}

then

thread::send $thr {foo ...}

-Alex
.



Relevant Pages

  • waiting for input of widget and return input value
    ... run proc1, then proc1 will invoke proc2 and popup some checkbutton for ... to invoke proc3, proc3 will check which button was checked and return a ... checked variable list, then proc2 return the list to proc1, and proc1 ... proc proc1 { ...
    (comp.lang.tcl)
  • Reg - Multi thread execution
    ... proc Proc1, Proc2, Proc3 are defined. ... sending the proc name to each thread for execution. ...
    (comp.lang.tcl)
  • Re: SP Permission Inheritance and Table Creation
    ... So what stops a user from 'sniffing' the app role password and then ... > role so that you can execute sp_rename. ... > EXEC sp_addapprole 'Maintenance', 'MaintenancePassword' ... > permissions on the proc are needed because the application role in this ...
    (microsoft.public.sqlserver.security)
  • Re: Performance Problem Using ADO and Stored Procs
    ... >I have a stored proc that executes in < 15 seconds through Query Analyzer. ... If I execute this proc ... > of CPU activity on the server hosting SQL server for the SQL server ... > Private Function RunProc(vntDB As Variant, strProcName As String, ...
    (microsoft.public.data.ado)
  • Re: Auditing SP Execute.
    ... > As long as the users only have execute permissions on the proc i.e. they ... This assumes that the app doesn't use a single ... > Jasper Smith (SQL Server MVP) ... >> particular sp was execute and by whom. ...
    (microsoft.public.sqlserver.security)