Lisener should run the void go(int param) method, but if the frequency of the launches is less than a second, then this should be considered a parasitic event. And the go method should not be run.

Those. you need to implement the void noiseFilter(int param) method, which would run go(param) in case the frequency of generating a log of less than 1 Hertz (no more than 1 time per second).

Help a newbie.

PS Time binding is not super critical, since 1Hz is a huge threshold, which covers the parasitic frequency tenfold.

    1 answer 1

    Look for articles about the timer as an option. I myself did not use the timer - but in my opinion, you can solve it this way: Create a flag in the class, implement the Drop function, which changes this flag to false. Next - when the function is launched, it checks the flag, if it is false - then you can work, if true - then the execution is completed. If the function can work, it sets this flag to true and starts TimerTask, which will reset this flag in a second using the Drop method.