public synchronized void stopThread() { plugin.getLogger().info("Stopping fetch thread..."); stop.set(true); try { this.wait(1000); plugin.getLogger().info("Stopped fetch thread successfully!"); } catch (InterruptedException ignored) { } }
@Override public void run() { int id = 0; Gson gson = new Gson(); while (!stop.get()) { try (Jedis jedis = plugin.getSlavePool().getResource()) { sleep(plugin.getLocalConfig().getFetchInterval()); List<String> block_l = jedis.lrange(plugin.getLocalConfig().getTableName(), id, -1); for (String s : block_l) { JsonObject data = gson.fromJson(s, JsonObject.class); plugin.getQueue().offer(data); } id += block_l.size(); } catch (InterruptedException e) { e.printStackTrace(); } } try { sleep(100); } catch (InterruptedException ignored) { } notifyAll(); }