Runnable runPickWinner = new Runnable() {
@Override
public void run() {
mPot.pickWinner();
}
};
ScheduledExecutorService execPickWinner = Executors.newScheduledThreadPool(1);
execPickWinner.scheduleAtFixedRate(runPickWinner, runPickWinnerTime.longValue(), runPickWinnerTime.longValue(), TimeUnit.MINUTES);
我收到以下錯誤:拋出:IllegalArgumentException上scheduleAtFixedRate方法
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)
一個錯誤,但它是沒有意義的,他們是整數類型的,後來我打電話longValue()
這應該會讓他們變得很長。我只有通過硬編碼的價值,例如,如果我使用10L或只有10它工作,但這不會。
給出了一個非常簡短的回答,說這是固定的,但它在答案審查隊列中被刪除。 OP,如果你能提供一個擴展的答案,那將是理想的,否則就會失敗。謝謝! – halfer