Forum Discussion
SmartBear_Suppo
Alumni
13 years agoHi again!
You do not want to do:
as this refers to the script instance, which will differ for each thread.
For example, running a load test at a MockService with this dispatch script:
...will result in:
What you instead do want to do is to synchronize on something that the threads have in common, e.g. the MockService object:
Regards
Henrik
SmartBear Software
You do not want to do:
synchronized(this){
%MYSCRIPT%
}
as this refers to the script instance, which will differ for each thread.
For example, running a load test at a MockService with this dispatch script:
log.info ("hello, this is "+this)
...will result in:
Wed May 23 10:57:43 CEST 2012:INFO:hello, this is Script3@1e9668d
Wed May 23 10:57:43 CEST 2012:INFO:hello, this is Script1@a3e85e
What you instead do want to do is to synchronize on something that the threads have in common, e.g. the MockService object:
synchronized(mockRequest.context.mockService){
%MYSCRIPT%
}
Regards
Henrik
SmartBear Software