Two Mindstorms touch sensors: how to determine which sensor was pressed? I'm trying do make simple program. Two motors, two touch sensors. Sensor one increases speed, sensor two decreases.

The whole program works very well but only with one sensor. When I put some logic that has "Wait for sensor two" brick it just fools around.

The algorithm is very simple:


Variable i - counts times sensors being pressed
Variable Znak (eng. sign) causes variable i to decrease if negative or increase if positive.
Motor speed is calculated by multiplying i by 10. 


How can I solve this kind of problem?
I found an answer. I read in a book that I can't fork in a loop. But I can do up to 4 separate threads. So I did 3 threads:


Running/changing motors speed based on a variable "i" which is changed in other threads.
Waiting for a touch sensor A being bumped and increasing var "i".
Waiting for a touch sensor B being bumped and decreasing var "i".