How to Pass Arguments to Timertask Run Method

后端 未结 5 763
悲&欢浪女
悲&欢浪女 2021-01-12 21:45

I have a method and I want it to be scheduled for execution in later times. The scheduling time and method\'s arguments depend on user inputs.

I already have tried T

5条回答
  •  独厮守ぢ
    2021-01-12 22:02

    The only way to do this is to create your own class that extends TimerTask and pass arguments to its constructor or call its setters. So, the task will "know" its arguments from the moment of its creation.

    Moreover if it provides setters you can modify the task configuration even later, after the task has been already scheduled.

提交回复
热议问题