首页 > 解决方案 > 在 Java 中通过定时器传递参数

问题描述

我想通过我的计时器传递一个参数。我看过这篇文章,将参数传递给定时器任务(Java),但它似乎使用了我正在使用的不同定时器。我也看过其他一些帖子,但似乎都没有。这是我的代码。

public static Timer sendObjects = new Timer();
    public static TimerTask sendTask = new TimerTask() {
        public void run() {
            //This is where I would use the variable I pass through
    };

我想将一个字符串数组传递给这个计时器任务。类似于您使用方法执行此操作的方式。我怎么能这样做,我会用什么来运行它?

标签: javaeclipse

解决方案


推荐阅读