JSR223 javascript - multiple instance of one rule


i’m running in basic problem with jsr223 javascript. How is it possible to catch events in a single rule in this pattern:

var startT = -1;
var runT = 0;
var x = 0;

var delayT = function() {
  if (runT == 0) {
    runT = 1;
    while ((startT + 4000) > (new Date().getTime())) {x = 0;}    // runs 4000ms 
    runT = 0;
    logInfo("FINISHED !!!!")
  } else {
    logInfo("is running ...")

var testR = JSRule({
  name: "testMulti",
  description: "only for testing",
  triggers: [ItemCommandTrigger("TestSwitch")],
  execute: function( module, input){

    logInfo("START *****");
    startT = new Date().getTime();
    logInfo("END *******")

Currently i see the follwowing behavior:
When the TestSwitch is pressed the rule testR is called, in the log i can see START and 4s later i see FINISHED and END. But when the TestSwitch, within the 4s, is pressed again the event is “perssisted” and after the logInfo - END the rule runs the second time.

I would expect when the TestSwitch is changed within the 4s the rule is triggerd in a second, third, … instance. Then the rule called the function delayT() and this should run in the else branch and write "is running …, because the variable runT is set to 1 in the first instance.

I’m running OH 2.4.0.

Thanks, Torsten