Tcl Source Code

Hex Artifact Content
Login

Artifact d9df6e4b1d9ae80dc6439af93aa230f1155f271c:

Attachment "SampleTestuite2.itcl" to ticket [1449394fff] added by dharan 2006-03-14 14:39:04. Also attachment "SampleTestuite2.itcl" to ticket [1449383fff] added by dharan 2006-03-14 13:57:47.
0000: 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 65  .package require
0010: 20 54 68 72 65 61 64 0a 0a 66 6f 72 20 7b 73 65   Thread..for {se
0020: 74 20 69 20 31 7d 20 7b 24 69 20 3c 20 31 35 7d  t i 1} {$i < 15}
0030: 20 7b 69 6e 63 72 20 69 7d 20 7b 0a 0a 20 20 20   {incr i} {..   
0040: 20 70 75 74 73 20 22 23 23 23 23 23 23 23 23 23   puts "#########
0050: 23 23 23 23 23 23 49 6e 73 69 64 65 20 54 65 73  ######Inside Tes
0060: 74 20 24 69 22 0a 20 20 20 20 61 66 74 65 72 20  t $i".    after 
0070: 35 30 30 30 20 7b 73 65 74 20 66 6c 61 67 20 31  5000 {set flag 1
0080: 7d 0a 20 20 20 20 73 65 74 20 73 63 72 69 70 74  }.    set script
0090: 20 7b 70 75 74 73 20 22 49 6e 73 69 64 65 20 54   {puts "Inside T
00a0: 68 72 65 61 64 22 0a 20 20 20 20 20 20 20 20 70  hread".        p
00b0: 75 74 73 20 22 49 6e 73 69 64 65 20 54 68 72 65  uts "Inside Thre
00c0: 61 64 22 0a 20 20 20 20 20 20 20 20 70 75 74 73  ad".        puts
00d0: 20 22 49 6e 73 69 64 65 20 54 68 72 65 61 64 22   "Inside Thread"
00e0: 0a 20 20 20 20 20 20 20 20 70 75 74 73 20 22 49  .        puts "I
00f0: 6e 73 69 64 65 20 54 68 72 65 61 64 22 0a 20 20  nside Thread".  
0100: 20 20 20 20 20 20 70 75 74 73 20 22 49 6e 73 69        puts "Insi
0110: 64 65 20 54 68 72 65 61 64 22 0a 20 20 20 20 20  de Thread".     
0120: 20 20 74 68 72 65 61 64 3a 3a 72 65 6c 65 61 73    thread::releas
0130: 65 0a 20 20 20 20 7d 0a 20 20 20 20 73 65 74 20  e.    }.    set 
0140: 6e 6f 54 68 72 65 61 64 20 35 20 20 20 20 20 0a  noThread 5     .
0150: 20 20 20 20 66 6f 72 20 7b 73 65 74 20 6e 20 31      for {set n 1
0160: 7d 20 7b 24 6e 20 3c 3d 20 24 6e 6f 54 68 72 65  } {$n <= $noThre
0170: 61 64 7d 20 7b 69 6e 63 72 20 6e 7d 20 7b 0a 20  ad} {incr n} {. 
0180: 20 20 20 20 20 20 20 65 76 61 6c 20 73 65 74 20         eval set 
0190: 74 68 72 65 61 64 49 64 24 6e 20 5b 74 68 72 65  threadId$n [thre
01a0: 61 64 3a 3a 63 72 65 61 74 65 20 2d 6a 6f 69 6e  ad::create -join
01b0: 61 62 6c 65 5d 20 20 20 20 20 20 20 0a 20 20 20  able]       .   
01c0: 20 7d 0a 20 20 20 20 66 6f 72 20 7b 73 65 74 20   }.    for {set 
01d0: 6e 20 31 7d 20 7b 24 6e 20 3c 3d 20 24 6e 6f 54  n 1} {$n <= $noT
01e0: 68 72 65 61 64 7d 20 7b 69 6e 63 72 20 6e 7d 20  hread} {incr n} 
01f0: 7b 20 0a 20 20 20 20 20 20 20 20 69 66 20 7b 5b  { .        if {[
0200: 63 61 74 63 68 20 7b 65 76 61 6c 20 74 68 72 65  catch {eval thre
0210: 61 64 3a 3a 73 65 6e 64 20 2d 61 73 79 6e 63 20  ad::send -async 
0220: 5c 24 74 68 72 65 61 64 49 64 24 6e 20 5c 24 73  \$threadId$n \$s
0230: 63 72 69 70 74 7d 20 6d 73 67 5d 7d 20 7b 0a 20  cript} msg]} {. 
0240: 20 20 20 20 20 20 20 20 20 20 20 65 72 72 6f 72             error
0250: 20 22 73 65 6e 64 20 73 63 72 69 70 74 20 66 61   "send script fa
0260: 69 6c 65 64 20 20 24 6d 73 67 20 3a 20 24 3a 3a  iled  $msg : $::
0270: 65 72 72 6f 72 49 6e 66 6f 22 0a 20 20 20 20 20  errorInfo".     
0280: 20 20 20 7d 0a 20 20 20 20 7d 0a 0a 20 20 20 20     }.    }..    
0290: 66 6f 72 20 7b 73 65 74 20 6e 20 31 7d 20 7b 24  for {set n 1} {$
02a0: 6e 20 3c 3d 20 24 6e 6f 54 68 72 65 61 64 7d 20  n <= $noThread} 
02b0: 7b 69 6e 63 72 20 6e 7d 20 7b 0a 20 20 20 20 20  {incr n} {.     
02c0: 20 20 20 65 76 61 6c 20 70 75 74 73 20 22 5c 22     eval puts "\"
02d0: 42 65 66 6f 72 65 20 4a 6f 69 6e 20 5c 24 74 68  Before Join \$th
02e0: 72 65 61 64 49 64 24 6e 5c 22 22 0a 20 20 20 20  readId$n\"".    
02f0: 20 20 20 20 65 76 61 6c 20 74 68 72 65 61 64 3a      eval thread:
0300: 3a 6a 6f 69 6e 20 5c 24 74 68 72 65 61 64 49 64  :join \$threadId
0310: 24 6e 0a 20 20 20 20 20 20 20 20 70 75 74 73 20  $n.        puts 
0320: 22 43 68 65 63 6b 20 24 74 68 72 65 61 64 49 64  "Check $threadId
0330: 31 20 65 78 69 73 74 20 5b 65 76 61 6c 20 74 68  1 exist [eval th
0340: 72 65 61 64 3a 3a 65 78 69 73 74 73 20 5c 24 74  read::exists \$t
0350: 68 72 65 61 64 49 64 24 6e 5d 22 0a 20 20 20 20  hreadId$n]".    
0360: 7d 0a 0a 20 20 20 20 70 75 74 73 20 22 57 61 69  }..    puts "Wai
0370: 74 69 6e 67 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ting............
0380: 2e 2e 2e 2e 2e 2e 24 69 22 0a 20 20 20 20 76 77  ......$i".    vw
0390: 61 69 74 20 66 6c 61 67 0a 0a 7d 0a 0a 23 20 65  ait flag..}..# e
03a0: 6e 64 20 6f 66 20 66 69 6c 65 0a                 nd of file.