scheduleAtFixedRate方法的IllegalArgumentException

时间:2017-05-07 03:04:04

标签: java

Runnable runPickWinner = new Runnable() {
        @Override
        public void run() {
            mPot.pickWinner();
        }
    };
ScheduledExecutorService execPickWinner = Executors.newScheduledThreadPool(1);
execPickWinner.scheduleAtFixedRate(runPickWinner, runPickWinnerTime.longValue(), runPickWinnerTime.longValue(), TimeUnit.MINUTES);

我收到以下错误:

java.lang.IllegalArgumentException
    at java.util.concurrent.ScheduledThreadPoolExecutor.scheduleAtFixedRate(Unknown Source) ~[?:1.8.0_131]
    at com.tchristofferson.Lottery.runLottery(Lottery.java:223) ~[?:?]
    at com.tchristofferson.Lottery.onEnable(Lottery.java:50) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:271) ~[craftbukkit.jar:git-Bukkit-c19c293]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:329) [craftbukkit.jar:git-Bukkit-c19c293]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:404) [craftbukkit.jar:git-Bukkit-c19c293]
    at org.bukkit.craftbukkit.v1_11_R1.CraftServer.enablePlugin(CraftServer.java:361) [craftbukkit.jar:git-Bukkit-c19c293]
    at org.bukkit.craftbukkit.v1_11_R1.CraftServer.enablePlugins(CraftServer.java:323) [craftbukkit.jar:git-Bukkit-c19c293]
    at net.minecraft.server.v1_11_R1.MinecraftServer.t(MinecraftServer.java:411) [craftbukkit.jar:git-Bukkit-c19c293]
    at net.minecraft.server.v1_11_R1.MinecraftServer.l(MinecraftServer.java:372) [craftbukkit.jar:git-Bukkit-c19c293]
    at net.minecraft.server.v1_11_R1.MinecraftServer.a(MinecraftServer.java:327) [craftbukkit.jar:git-Bukkit-c19c293]
    at net.minecraft.server.v1_11_R1.DedicatedServer.init(DedicatedServer.java:244) [craftbukkit.jar:git-Bukkit-c19c293]
    at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:521) [craftbukkit.jar:git-Bukkit-c19c293]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]

scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)似乎是一个错误,但它没有意义它们是Integer类型,但后来我调用longValue()这应该把它们变成一个long。我只是通过对其中的值进行硬编码来实现这一点,例如,如果我使用10L或者仅使用10,那么这不会。

0 个答案:

没有答案