Here the code of "mt91.rex", changes (compared to "mt90.rex") in bold, i.e.
commenting :
say "--->" .context~name
trace r
t=.Test~new
t~m1
t~m2
*-- t~block -- wait for both methods to complete* *t**~**start(**"M1"**) **-- asynchroneous!
**t**~**start(**"M2"**) **-- asynchroneous!* *-- t~block -- wait for both methods to complete*
t~start("M1")
t~start("M2")
*-- t~block -- wait for both methods to complete* ::class Test-- a test
class ::attribute counter-- an attribute/an object variable ::method init--
constructor expose counter-- must be very first statement trace a
say "arrived in:" .context~name
counter=0 ::method m1-- guarded method expose counter-- must be very
first statement trace a
counter+=1 -- increase counter say "arrived in:" .context~name"before
reply" call syssleep getSleepTime()-- randomly sleep reply tsk=1 -- to show up in trace call
syssleep getSleepTime()-- randomly sleep tsk=2 -- to show up in trace ::method m2unguarded --
unguarded method trace a
say "arrived in:" .context~name"before reply" call syssleep getSleepTime()--
randomly sleep reply call syssleep getSleepTime()-- randomly sleep self~counter=self~counter-1 --
decrease counter ::method block-- block caller, if counter<>0 expose counter-- must be very first
statement guard on when counter=0 -- attribute used as control variable return 99 ::routine getSleepTime
t=random(1,10)
return t/1000
---
The following traces occurred from /*mt91.rex *//*running on two different Rexx interpreter
instances (RII)!*/
Trace output without thread number (start of the 'mt91.rex' program on its RII in bold, includes
invocation sequence number):
*---> mt91.rex_nr_1_via_JSR223*
3 *-* t=.Test~new
21 *-* say "arrived in:" .context~name
arrived in: INIT
22 *-* counter=0
>>> "a TEST"
4 *-* t~m1
27 *-* counter+=1 -- increase counter
28 *-* say "arrived in:" .context~name "before reply"
arrived in: M1 before reply
29 *-* call syssleep getSleepTime() -- randomly sleep
30 *-* reply
5 *-* t~m2
>I> Method "M1" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
37 *-* say "arrived in:" .context~name "before reply"
arrived in: M2 before reply
31 *-* tsk=1 -- to show up in trace
38 *-* call syssleep getSleepTime() -- randomly sleep
32 *-* call syssleep getSleepTime() -- randomly sleep
39 *-* reply
33 *-* tsk=2 -- to show up in trace
7 *-* t~start("M1") -- asynchroneous!
>I> Method "M2" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
>>> "a Message"
27 *-* counter+=1 -- increase counter
40 *-* call syssleep getSleepTime() -- randomly sleep
8 *-* t~start("M2") -- asynchroneous!
28 *-* say "arrived in:" .context~name "before reply"
arrived in: M1 before reply
>>> "a Message"
37 *-* say "arrived in:" .context~name "before reply"
arrived in: M2 before reply
29 *-* call syssleep getSleepTime() -- randomly sleep
10 *-* t~start("M1")
41 *-* self~counter=self~counter-1 -- decrease counter
38 *-* call syssleep getSleepTime() -- randomly sleep
>>> "a Message"
11 *-* t~start("M2")
>>> "a Message"
37 *-* say "arrived in:" .context~name "before reply"
arrived in: M2 before reply
30 *-* reply
39 *-* reply
38 *-* call syssleep getSleepTime() -- randomly sleep
>I> Method "M1" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
>I> Method "M2" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
31 *-* tsk=1 -- to show up in trace
40 *-* call syssleep getSleepTime() -- randomly sleep
39 *-* reply
32 *-* call syssleep getSleepTime() -- randomly sleep
>I> Method "M2" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
40 *-* call syssleep getSleepTime() -- randomly sleep
41 *-* self~counter=self~counter-1 -- decrease counter
33 *-* tsk=2 -- to show up in trace
27 *-* counter+=1 -- increase counter
28 *-* say "arrived in:" .context~name "before reply"
*---> mt91.rex_nr_2_via_JSR223*
arrived in: M1 before reply
3 *-* t=.Test~new
29 *-* call syssleep getSleepTime() -- randomly sleep
21 *-* say "arrived in:" .context~name
41 *-* self~counter=self~counter-1 -- decrease counter
arrived in: INIT
22 *-* counter=0
>>> "a TEST"
4 *-* t~m1
27 *-* counter+=1 -- increase counter
28 *-* say "arrived in:" .context~name "before reply"
arrived in: M1 before reply
29 *-* call syssleep getSleepTime() -- randomly sleep
30 *-* reply
>I> Method "M1" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
31 *-* tsk=1 -- to show up in trace
32 *-* call syssleep getSleepTime() -- randomly sleep
30 *-* reply
33 *-* tsk=2 -- to show up in trace
5 *-* t~m2
>I> Method "M1" with scope "TEST" in package
"mt91.rex_nr_2_via_JSR223".
37 *-* say "arrived in:" .context~name "before reply"
arrived in: M2 before reply
31 *-* tsk=1 -- to show up in trace
38 *-* call syssleep getSleepTime() -- randomly sleep
32 *-* call syssleep getSleepTime() -- randomly sleep
39 *-* reply
7 *-* t~start("M1") -- asynchroneous!
>I> Method "M2" with scope "TEST" in package
"mt91.rex_nr_2_via_JSR223".
>>> "a Message"
40 *-* call syssleep getSleepTime() -- randomly sleep
8 *-* t~start("M2") -- asynchroneous!
>>> "a Message"
37 *-* say "arrived in:" .context~name "before reply"
arrived in: M2 before reply
10 *-* t~start("M1")
38 *-* call syssleep getSleepTime() -- randomly sleep
>>> "a Message"
11 *-* t~start("M2")
>>> "a Message"
Trace ouput with thread number (start of the 'mt91.rex' program on its RII in bold, includes
invocation sequence number):
*---> mt91.rex_nr_1_via_JSR223*
3 *- 1* t=.Test~new
21 *- 1* say "arrived in:" .context~name
arrived in: INIT
22 *- 1* counter=0
>> 1> "a TEST"
4 *- 1* t~m1
27 *- 1* counter+=1 -- increase counter
28 *- 1* say "arrived in:" .context~name "before reply"
arrived in: M1 before reply
29 *- 1* call syssleep getSleepTime() -- randomly sleep
30 *- 1* reply
5 *- 1* t~m2
>I 2> Method "M1" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
37 *- 1* say "arrived in:" .context~name "before reply"
arrived in: M2 before reply
31 *- 2* tsk=1 -- to show up in trace
38 *- 1* call syssleep getSleepTime() -- randomly sleep
32 *- 2* call syssleep getSleepTime() -- randomly sleep
39 *- 1* reply
33 *- 2* tsk=2 -- to show up in trace
7 *- 1* t~start("M1") -- asynchroneous!
>I 3> Method "M2" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
>> 1> "a Message"
27 *- 2* counter+=1 -- increase counter
40 *- 3* call syssleep getSleepTime() -- randomly sleep
8 *- 1* t~start("M2") -- asynchroneous!
28 *- 2* say "arrived in:" .context~name "before reply"
arrived in: M1 before reply
>> 1> "a Message"
37 *- 4* say "arrived in:" .context~name "before reply"
arrived in: M2 before reply
29 *- 2* call syssleep getSleepTime() -- randomly sleep
10 *- 1* t~start("M1")
41 *- 3* self~counter=self~counter-1 -- decrease counter
38 *- 4* call syssleep getSleepTime() -- randomly sleep
>> 1> "a Message"
11 *- 1* t~start("M2")
>> 1> "a Message"
37 *- 5* say "arrived in:" .context~name "before reply"
arrived in: M2 before reply
30 *- 2* reply
39 *- 4* reply
38 *- 5* call syssleep getSleepTime() -- randomly sleep
>I 6> Method "M1" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
>I 2> Method "M2" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
31 *- 6* tsk=1 -- to show up in trace
40 *- 2* call syssleep getSleepTime() -- randomly sleep
39 *- 5* reply
32 *- 6* call syssleep getSleepTime() -- randomly sleep
>I 4> Method "M2" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
40 *- 4* call syssleep getSleepTime() -- randomly sleep
41 *- 2* self~counter=self~counter-1 -- decrease counter
33 *- 6* tsk=2 -- to show up in trace
27 *- 7* counter+=1 -- increase counter
28 *- 7* say "arrived in:" .context~name "before reply"
*---> mt91.rex_nr_2_via_JSR223*
arrived in: M1 before reply
3 *- 1* t=.Test~new
29 *- 7* call syssleep getSleepTime() -- randomly sleep
21 *- 1* say "arrived in:" .context~name
41 *- 4* self~counter=self~counter-1 -- decrease counter
arrived in: INIT
22 *- 1* counter=0
>> 1> "a TEST"
4 *- 1* t~m1
27 *- 1* counter+=1 -- increase counter
28 *- 1* say "arrived in:" .context~name "before reply"
arrived in: M1 before reply
29 *- 1* call syssleep getSleepTime() -- randomly sleep
30 *- 7* reply
>I 5> Method "M1" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
31 *- 5* tsk=1 -- to show up in trace
32 *- 5* call syssleep getSleepTime() -- randomly sleep
30 *- 1* reply
33 *- 5* tsk=2 -- to show up in trace
5 *- 1* t~m2
>I 6> Method "M1" with scope "TEST" in package
"mt91.rex_nr_2_via_JSR223".
37 *- 1* say "arrived in:" .context~name "before reply"
arrived in: M2 before reply
31 *- 6* tsk=1 -- to show up in trace
38 *- 1* call syssleep getSleepTime() -- randomly sleep
32 *- 6* call syssleep getSleepTime() -- randomly sleep
39 *- 1* reply
7 *- 1* t~start("M1") -- asynchroneous!
>I 7> Method "M2" with scope "TEST" in package
"mt91.rex_nr_2_via_JSR223".
>> 1> "a Message"
40 *- 7* call syssleep getSleepTime() -- randomly sleep
8 *- 1* t~start("M2") -- asynchroneous!
>> 1> "a Message"
37 *- 3* say "arrived in:" .context~name "before reply"
arrived in: M2 before reply
10 *- 1* t~start("M1")
38 *- 3* call syssleep getSleepTime() -- randomly sleep
>> 1> "a Message"
11 *- 1* t~start("M2")
>> 1> "a Message"
Remark: despite the thread number it is not possible to identify and distinguish the different
activities in the above output as we cannot learn which thread is used by which activity. Also it is
not possible to know which trace output belongs to which program i.e. which RII runs which activity
on which thread.
Multithreading trace output activated:
---> mt91.rex_nr_1_via_JSR223
R1 T1 A1 3 *-* t=.Test~new
R1 T1 A2 V1 1* 21 *-* say "arrived in:" .context~name
arrived in: INIT
R1 T1 A2 V1 1* 22 *-* counter=0
R1 T1 A1 >>> "a TEST"
R1 T1 A1 4 *-* t~m1
R1 T1 A3 V1 1* 27 *-* counter+=1 -- increase counter
R1 T1 A3 V1 1* 28 *-* say "arrived in:" .context~name "before
reply"
arrived in: M1 before reply
R1 T1 A3 V1 1* 29 *-* call syssleep getSleepTime() --
randomly sleep
R1 T1 A3 V1 1* 30 *-* reply
R1 T1 A1 5 *-* t~m2
R1 T2 A3 V1 1* >I> Method "M1" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
R1 T1 A4 V1 1 37 *-* say "arrived in:" .context~name "before
reply"
arrived in: M2 before reply
R1 T2 A3 V1 1* 31 *-* tsk=1 -- to show up in
trace
R1 T1 A4 V1 1 38 *-* call syssleep getSleepTime() --
randomly sleep
R1 T2 A3 V1 1* 32 *-* call syssleep getSleepTime() --
randomly sleep
R1 T1 A4 V1 1 39 *-* reply
R1 T2 A3 V1 1* 33 *-* tsk=2 -- to show up in
trace
R1 T1 A1 7 *-* t~start("M1") -- asynchroneous!
R1 T3 A4 V1 1 >I> Method "M2" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
R1 T1 A1 >>> "a Message"
R1 T2 A5 V1 1* 27 *-* counter+=1 -- increase counter
R1 T3 A4 V1 1 40 *-* call syssleep getSleepTime() --
randomly sleep
R1 T1 A1 8 *-* t~start("M2") -- asynchroneous!
R1 T2 A5 V1 1* 28 *-* say "arrived in:" .context~name "before
reply"
arrived in: M1 before reply
R1 T1 A1 >>> "a Message"
R1 T4 A6 V1 1 37 *-* say "arrived in:" .context~name "before
reply"
arrived in: M2 before reply
R1 T2 A5 V1 1* 29 *-* call syssleep getSleepTime() --
randomly sleep
R1 T1 A1 10 *-* t~start("M1")
R1 T3 A4 V1 1 41 *-* self~counter=self~counter-1 --
decrease counter
R1 T4 A6 V1 1 38 *-* call syssleep getSleepTime() --
randomly sleep
R1 T1 A1 >>> "a Message"
R1 T1 A1 11 *-* t~start("M2")
R1 T1 A1 >>> "a Message"
R1 T5 A7 V1 1 37 *-* say "arrived in:" .context~name "before
reply"
arrived in: M2 before reply
R1 T2 A5 V1 1* 30 *-* reply
R1 T4 A6 V1 1 39 *-* reply
R1 T5 A7 V1 1 38 *-* call syssleep getSleepTime() --
randomly sleep
R1 T6 A5 V1 1* >I> Method "M1" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
R1 T2 A6 V1 1 >I> Method "M2" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
R1 T6 A5 V1 1* 31 *-* tsk=1 -- to show up in
trace
R1 T2 A6 V1 1 40 *-* call syssleep getSleepTime() --
randomly sleep
R1 T5 A7 V1 1 39 *-* reply
R1 T6 A5 V1 1* 32 *-* call syssleep getSleepTime() --
randomly sleep
R1 T4 A7 V1 1 >I> Method "M2" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
R1 T4 A7 V1 1 40 *-* call syssleep getSleepTime() --
randomly sleep
R1 T2 A6 V1 1 41 *-* self~counter=self~counter-1 --
decrease counter
R1 T6 A5 V1 1* 33 *-* tsk=2 -- to show up in
trace
R1 T7 A8 V1 1* 27 *-* counter+=1 -- increase counter
R1 T7 A8 V1 1* 28 *-* say "arrived in:" .context~name "before
reply"
---> mt91.rex_nr_2_via_JSR223
arrived in: M1 before reply
R2 T1 A9 3 *-* t=.Test~new
R1 T7 A8 V1 1* 29 *-* call syssleep getSleepTime() --
randomly sleep
R2 T1 A10 V2 1* 21 *-* say "arrived in:" .context~name
R1 T4 A7 V1 1 41 *-* self~counter=self~counter-1 --
decrease counter
arrived in: INIT
R2 T1 A10 V2 1* 22 *-* counter=0 R2 T1 A9 >>> "a TEST" R2 T1 A9 4 *-* t~m1
R2 T1 A11 V2 1* 27
*-* counter+=1 -- increase counter R2 T1 A11 V2 1* 28 *-* say "arrived in:"
.context~name
"before reply"
arrived in: M1 before reply
R2 T1 A11 V2 1* 29 *-* call syssleep getSleepTime() -- randomly sleep
R1 T7 A8 V1 1* 30 *-* reply
R1 T5 A8 V1 1* >I> Method "M1" with scope "TEST" in package
"mt91.rex_nr_1_via_JSR223".
R1 T5 A8 V1 1* 31 *-* tsk=1 -- to show up in
trace
R1 T5 A8 V1 1* 32 *-* call syssleep getSleepTime() --
randomly sleep
R2 T1 A11 V2 1* 30 *-* reply
R1 T5 A8 V1 1* 33 *-* tsk=2 -- to show up in
trace
R2 T1 A9 5 *-* t~m2 R2 T6 A11 V2 1* >I> Method "M1" with scope "TEST" in
package
"mt91.rex_nr_2_via_JSR223". R2 T1 A12 V2 1 37 *-* say "arrived in:" .context~name
"before reply"
arrived in: M2 before reply
R2 T6 A11 V2 1* 31 *-* tsk=1 -- to show up in trace R2 T1 A12 V2 1 38 *-*
call syssleep
getSleepTime() -- randomly sleep R2 T6 A11 V2 1* 32 *-* call syssleep
getSleepTime() -- randomly
sleep R2 T1 A12 V2 1 39 *-* reply R2 T1 A9 7 *-* t~start("M1") --
asynchroneous! R2 T7 A12 V2 1
>I> Method "M2" with scope "TEST" in package "mt91.rex_nr_2_via_JSR223". R2 T1 A9
>>> "a
Message" R2 T7 A12 V2 1 40 *-* call syssleep getSleepTime() -- randomly
sleep R2 T1 A9 8 *-*
t~start("M2") -- asynchroneous! R2 T1 A9 >>> "a Message" R2 T3 A13 V2 1 37 *-* say
"arrived in:"
.context~name "before reply"
arrived in: M2 before reply
R2 T1 A9 10 *-* t~start("M1") R2 T3 A13 V2 1 38 *-* call syssleep
getSleepTime() -- randomly
sleep R2 T1 A9 >>> "a Message" R2 T1 A9 11 *-* t~start("M2") R2 T1 A9 >>> "a
Message"
Remark: it is fairly easy to identify and distinguish the different activities (and see how they get
interleaved with other activities). It is possible to see which activities and threads get used by
which RII, highlighting R2 in green.
---rony
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel