ThreadPool manager rework.

This commit is contained in:
MobiusDev
2017-08-23 05:23:31 +00:00
parent 374c53df4b
commit b77de360af
718 changed files with 3180 additions and 7193 deletions

View File

@@ -132,33 +132,29 @@ SkillCheckGM = False
# Thread Configuration
# ---------------------------------------------------------------------------
# Extreme caution should be here, set to defaults if you do not know what you are doing.
# These could possibly hurt your servers performance or improve it depending on your server's configuration, size, and other factors.
# Default: 10
ThreadPoolSizeEffects = 50
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
Default: -1
ScheduledThreadPoolCount = -1
# Default: 13
ThreadPoolSizeGeneral = 65
# Specifies how many threads will be in a single scheduled pool.
Default: 4
ThreadsPerScheduledThreadPool = 40
# Default: 2
ThreadPoolSizeEvents = 10
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
Default: -1
InstantThreadPoolCount = -1
# Specifies how many threads will be in a single instant pool.
Default: 2
ThreadsPerInstantThreadPool = 20
# Default: 2
UrgentPacketThreadCoreSize = 20
# Default: 4
GeneralPacketThreadCoreSize = 20
# Default: 4
GeneralThreadCoreSize = 20
# Default: 6
AiMaxThread = 30
# Default: 5
EventsMaxThread = 25
# Dead Lock Detector (a separate thread for detecting deadlocks).
# ---------------------------------------------------------------------------
# Dead Lock Detector (separate thread for detecting deadlocks)
# ---------------------------------------------------------------------------
# For improved crash logs and automatic restart in deadlock case if enabled.
# Check interval is in seconds.
# Default: True

View File

@@ -8,7 +8,6 @@
</tr>
</table>
<br>
<br>
<font color="LEVEL">General:<font><br1>
<table width="270" border="0" bgcolor="444444">
<tr>
@@ -76,30 +75,5 @@
<td><font color="00FF00">%totalMem% MB</font></td>
</tr>
</table>
<br>
<font color="LEVEL">Thread - General (STP):<font><br1>
%theardInfoGen%
<br>
<font color="LEVEL">Thread - Effects (STP):<font><br1>
%theardInfoEff%
<br>
<font color="LEVEL">Thread - AI (STP):<font><br1>
%theardInfoAi%
<br>
<font color="LEVEL">Thread - Event (STP):<font><br1>
%theardInfoEvent%
<br>
<font color="LEVEL">Thread - Packets (TP):<font><br1>
%theardInfoPack%
<br>
<font color="LEVEL">Thread - I/O Packets (TP):<font><br1>
%theardInfoIOPack%
<br>
<font color="LEVEL">Thread - General Tasks (TP):<font><br1>
%theardInfoGenTask%
<br>
<font color="LEVEL">Thread - Event Tasks (TP):<font><br1>
%theardInfoEvnTask%
<br>
</center>
</body></html>

View File

@@ -127,7 +127,7 @@ public final class DenOfEvil extends AbstractNpcAI
zone.addSkill(skillId, skillLevel + 1);
if (skillLevel == 3) // 3+1=4
{
ThreadPoolManager.getInstance().scheduleAi(new KashaDestruction(zone), 2 * 60 * 1000l);
ThreadPoolManager.schedule(new KashaDestruction(zone), 2 * 60 * 1000l);
zone.broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.DEFEAT_KASHA_S_EYES_TO_LIFT_THE_GREAT_CURSE));
}
else if (skillLevel == 2)
@@ -140,7 +140,7 @@ public final class DenOfEvil extends AbstractNpcAI
@Override
public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
{
ThreadPoolManager.getInstance().scheduleAi(new RespawnNewEye(npc.getLocation()), 15000);
ThreadPoolManager.schedule(new RespawnNewEye(npc.getLocation()), 15000);
final L2EffectZone zone = ZoneManager.getInstance().getZone(npc, L2EffectZone.class);
if (zone == null)
{
@@ -213,7 +213,7 @@ public final class DenOfEvil extends AbstractNpcAI
final L2Npc npc = (L2Npc) character;
if (CommonUtil.contains(EYE_IDS, npc.getId()))
{
ThreadPoolManager.getInstance().scheduleAi(new RespawnNewEye(npc.getLocation()), 15000);
ThreadPoolManager.schedule(new RespawnNewEye(npc.getLocation()), 15000);
}
}
}

View File

@@ -129,11 +129,11 @@ public final class Parade extends AbstractNpcAI
{
// Starts at 8:00 and repeats every 6 hours.
final long diff = timeLeftMilli(8, 0, 0), cycle = 3600000L;
ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Start(), diff, cycle);
ThreadPoolManager.scheduleAtFixedRate(new Start(), diff, cycle);
// Test - Starts 3 minutes after server startup and repeats every 20 minutes.
// final long diff = timeLeftMilli(8, 0, 0), cycle = 600000L;
// ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Start(), 180000L, cycle);
// ThreadPoolManager.scheduleAtFixedRate(new Start(), 180000L, cycle);
_log.info("Fantasy Isle: Parade starting at " + new SimpleDateFormat("yyyy/MM/dd HH:mm").format(System.currentTimeMillis() + diff) + " and is scheduled each next " + (cycle / 3600000) + " hours.");
}
@@ -171,9 +171,9 @@ public final class Parade extends AbstractNpcAI
public void run()
{
load();
spawnTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Spawn(), 0, 5000);
deleteTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Delete(), 10000, 1000);
cleanTask = ThreadPoolManager.getInstance().scheduleGeneral(new Clean(), 420000);
spawnTask = ThreadPoolManager.scheduleAtFixedRate(new Spawn(), 0, 5000);
deleteTask = ThreadPoolManager.scheduleAtFixedRate(new Delete(), 10000, 1000);
cleanTask = ThreadPoolManager.schedule(new Clean(), 420000);
}
}

View File

@@ -141,7 +141,7 @@ public final class GainakSiege extends AbstractNpcAI
final L2SiegeZone zone = ZoneManager.getInstance().getZone(npc, L2SiegeZone.class);
if ((zone != null) && (zone.getId() == 60019) && zone.isActive())
{
ThreadPoolManager.getInstance().scheduleAi(new RespawnNewAssassin(npc.getLocation()), 60000);
ThreadPoolManager.schedule(new RespawnNewAssassin(npc.getLocation()), 60000);
}
return super.onKill(npc, killer, isSummon);
}

View File

@@ -256,7 +256,7 @@ public final class FourSepulchers extends AbstractNpcAI implements IGameXmlReade
if ((doorInfo[0] == sepulcherId) && (doorInfo[1] == currentWave))
{
openDoor(doorInfo[2], 0);
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
closeDoor(doorInfo[2], 0);
}, 15000);
@@ -578,7 +578,7 @@ public final class FourSepulchers extends AbstractNpcAI implements IGameXmlReade
showHtmlFile(player, npcId + "-OK.html", npc, null);
// Kick all players when/if time is over
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
ZoneManager.getInstance().getZoneById(MANAGER_ZONES.get(npcId)).oustAllPlayers();
}, TIME_ATTACK * 60 * 1000);

View File

@@ -109,7 +109,7 @@ public class AltarOfSacrifice extends AbstractNpcAI
private void sendMessage(L2Npc npc, NpcStringId npcString, int delay)
{
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
if (npc != null)
{

View File

@@ -349,7 +349,7 @@ public final class AwakeningMaster extends AbstractNpcAI
player.sendSkillList();
}
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
player.sendPacket(ExShowUsm.AWAKENING_END);
}, 10000);

View File

@@ -174,7 +174,7 @@ public class HarnakUndergroundRuinsZone extends AbstractNpcAI
_templates.stream().forEach(t -> t.spawn(g -> String.valueOf(g.getName()).equalsIgnoreCase(zoneName.concat("_demonic")), null));
zone.getPlayersInside().forEach(temp -> temp.sendPacket(new ExSendUIEvent(temp, false, false, 600, 0, NpcStringId.DEMONIC_SYSTEM_ACTIVATED)));
currentInfo.setZoneStage(7);
ThreadPoolManager.getInstance().scheduleGeneral(new changeZoneStage(zone), 600000); // 10min
ThreadPoolManager.schedule(new changeZoneStage(zone), 600000); // 10min
}
else
{
@@ -202,7 +202,7 @@ public class HarnakUndergroundRuinsZone extends AbstractNpcAI
if (currentInfo.getZoneStage() < 6)
{
currentInfo.setZoneStage(currentInfo.getZoneStage() + 1);
ThreadPoolManager.getInstance().scheduleGeneral(new changeZoneStage(zone), 5000);
ThreadPoolManager.schedule(new changeZoneStage(zone), 5000);
}
}
catch (Exception e)
@@ -248,7 +248,7 @@ public class HarnakUndergroundRuinsZone extends AbstractNpcAI
if (calcPoints >= 300)
{
calcPoints = 300;
ThreadPoolManager.getInstance().scheduleGeneral(new changeZoneStage(currentZone.getKey()), 1000);
ThreadPoolManager.schedule(new changeZoneStage(currentZone.getKey()), 1000);
}
currentInfo.setCurrentPoint(calcPoints);
for (L2PcInstance player : currentZone.getKey().getPlayersInside())

View File

@@ -258,7 +258,7 @@ public final class QueenAnt extends AbstractNpcAI
{
((L2MonsterInstance) npc).getMinionList().spawnMinions(npc.getParameters().getMinionList("Privates"));
}
_task = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new QueenAntTask(), 5 * 1000, 5 * 1000);
_task = ThreadPoolManager.scheduleAtFixedRate(new QueenAntTask(), 5 * 1000, 5 * 1000);
break;
}
}

View File

@@ -701,7 +701,7 @@ public final class EnergySeeds extends AbstractNpcAI
public void scheduleRespawn(long waitTime)
{
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
// if the AI is inactive, do not spawn the NPC
if (isSeedActive(_seedId))

View File

@@ -90,6 +90,6 @@ public class NpcBufferAI implements Runnable
_npc.doCast(skill);
ThreadPoolManager.getInstance().scheduleGeneral(this, skill.getReuseDelay());
ThreadPoolManager.schedule(this, skill.getReuseDelay());
}
}

View File

@@ -53,7 +53,7 @@ public final class NpcBuffers extends AbstractNpcAI
final NpcBufferData data = _npcBuffers.getNpcBuffer(npc.getId());
for (NpcBufferSkillData skill : data.getSkills())
{
ThreadPoolManager.getInstance().scheduleAi(new NpcBufferAI(npc, skill), skill.getInitialDelay());
ThreadPoolManager.schedule(new NpcBufferAI(npc, skill), skill.getInitialDelay());
}
return super.onSpawn(npc);
}

View File

@@ -112,7 +112,7 @@ public final class Elpies extends Event
Broadcast.toAllOnlinePlayers("Help us exterminate them!");
Broadcast.toAllOnlinePlayers("You have " + EVENT_DURATION_MINUTES + " minutes!");
_eventTask = ThreadPoolManager.getInstance().scheduleGeneral(() ->
_eventTask = ThreadPoolManager.schedule(() ->
{
Broadcast.toAllOnlinePlayers("Time is up!");
eventStop();

View File

@@ -138,7 +138,7 @@ public final class Race extends Event
Broadcast.toAllOnlinePlayers("Visit Event Manager in Dion village and signup, you have " + _time_register + " min before Race Start...");
// Schedule Event end
_eventTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> StartRace(), _time_register * 60 * 1000);
_eventTask = ThreadPoolManager.schedule(() -> StartRace(), _time_register * 60 * 1000);
return true;
@@ -181,7 +181,7 @@ public final class Race extends Event
}
}
// Schedule timeup for Race
_eventTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> timeUp(), _time_race * 60 * 1000);
_eventTask = ThreadPoolManager.schedule(() -> timeUp(), _time_race * 60 * 1000);
}
@Override

View File

@@ -308,7 +308,6 @@ import handlers.telnethandlers.server.ServerAbort;
import handlers.telnethandlers.server.ServerRestart;
import handlers.telnethandlers.server.ServerShutdown;
import handlers.telnethandlers.server.Status;
import handlers.telnethandlers.server.ThreadPoolDebug;
import handlers.usercommandhandlers.ChannelDelete;
import handlers.usercommandhandlers.ChannelInfo;
import handlers.usercommandhandlers.ChannelLeave;
@@ -749,7 +748,6 @@ public class MasterHandler
TelnetServer.getInstance().addHandler(new ServerRestart());
TelnetServer.getInstance().addHandler(new ServerShutdown());
TelnetServer.getInstance().addHandler(new Status());
TelnetServer.getInstance().addHandler(new ThreadPoolDebug());
TelnetServer.getInstance().addHandler(new handlers.telnethandlers.server.Debug());
}

View File

@@ -107,7 +107,7 @@ public class AdminMonsterRace implements IAdminCommandHandler
activeChar.sendPacket(spk);
activeChar.broadcastPacket(spk);
ThreadPoolManager.getInstance().scheduleGeneral(new RunRace(codes, activeChar), 5000);
ThreadPoolManager.schedule(new RunRace(codes, activeChar), 5000);
}
}
@@ -137,7 +137,7 @@ public class AdminMonsterRace implements IAdminCommandHandler
final MonRaceInfo spk = new MonRaceInfo(codes[2][0], codes[2][1], MonsterRace.getInstance().getMonsters(), MonsterRace.getInstance().getSpeeds());
activeChar.sendPacket(spk);
activeChar.broadcastPacket(spk);
ThreadPoolManager.getInstance().scheduleGeneral(new RunEnd(activeChar), 30000);
ThreadPoolManager.schedule(new RunEnd(activeChar), 30000);
}
}

View File

@@ -20,14 +20,12 @@ import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.GameServer;
import com.l2jmobius.gameserver.GameTimeController;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
@@ -72,14 +70,6 @@ public class AdminServerInfo implements IAdminCommandHandler
html.replace("%usedMem%", (RunTime.maxMemory() / mb) - (((RunTime.maxMemory() - RunTime.totalMemory()) + RunTime.freeMemory()) / mb));
html.replace("%freeMem%", ((RunTime.maxMemory() - RunTime.totalMemory()) + RunTime.freeMemory()) / mb);
html.replace("%totalMem%", Runtime.getRuntime().maxMemory() / 1048576);
html.replace("%theardInfoGen%", buildTheardInfo("GENERAL"));
html.replace("%theardInfoEff%", buildTheardInfo("EFFECTS"));
html.replace("%theardInfoAi%", buildTheardInfo("AI"));
html.replace("%theardInfoEvent%", buildTheardInfo("EVENT"));
html.replace("%theardInfoPack%", buildTheardInfo("PACKETS"));
html.replace("%theardInfoIOPack%", buildTheardInfo("IOPACKETS"));
html.replace("%theardInfoGenTask%", buildTheardInfo("GENERAL_TASKS"));
html.replace("%theardInfoEvnTask%", buildTheardInfo("EVENT_TASKS"));
activeChar.sendPacket(html);
}
return true;
@@ -96,22 +86,6 @@ public class AdminServerInfo implements IAdminCommandHandler
return days + " Days, " + hours + " Hours, " + TimeUnit.MILLISECONDS.toMinutes(time) + " Minutes";
}
private String buildTheardInfo(String category)
{
final StringBuilder tb = new StringBuilder();
tb.append("<table width=\"270\" border=\"0\" bgcolor=\"444444\">");
for (Entry<String, Object> info : ThreadPoolManager.getInstance().getStats(category).getSet().entrySet())
{
tb.append("<tr>");
tb.append("<td>" + info.getKey() + ":</td>");
tb.append("<td><font color=\"00FF00\">" + info.getValue() + "</font></td>");
tb.append("</tr>");
}
tb.append("</table>");
return tb.toString();
}
private int getPlayersCount(String type)
{
switch (type)

View File

@@ -46,7 +46,7 @@ public class AdminTest implements IAdminCommandHandler
{
if (command.equals("admin_stats"))
{
for (String line : ThreadPoolManager.getInstance().getStats())
for (String line : ThreadPoolManager.getStats())
{
activeChar.sendMessage(line);
}

View File

@@ -57,7 +57,7 @@ public class ClassChange extends AbstractEffect
{
final L2PcInstance player = effected.getActingPlayer();
// TODO: FIX ME - Executing 1 second later otherwise interupted exception during storeCharBase()
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
final int activeClass = player.getClassId().getId();

View File

@@ -67,7 +67,7 @@ public final class ServitorShare extends AbstractEffect
if (effected != null)
{
ThreadPoolManager.getInstance().scheduleEffect(new ScheduledEffectExitTask(effected, info.getSkill().getId()), 100);
ThreadPoolManager.schedule(new ScheduledEffectExitTask(effected, info.getSkill().getId()), 100);
}
}
}

View File

@@ -162,7 +162,7 @@ public class JailHandler implements IPunishmentHandler
OlympiadManager.getInstance().removeDisconnectedCompetitor(player);
}
ThreadPoolManager.getInstance().scheduleGeneral(new TeleportTask(player, L2JailZone.getLocationIn()), 2000);
ThreadPoolManager.schedule(new TeleportTask(player, L2JailZone.getLocationIn()), 2000);
// Open a Html message to inform the player
final NpcHtmlMessage msg = new NpcHtmlMessage();
@@ -198,7 +198,7 @@ public class JailHandler implements IPunishmentHandler
*/
private static void removeFromPlayer(L2PcInstance player)
{
ThreadPoolManager.getInstance().scheduleGeneral(new TeleportTask(player, L2JailZone.getLocationOut()), 2000);
ThreadPoolManager.schedule(new TeleportTask(player, L2JailZone.getLocationOut()), 2000);
// Open a Html message to inform the player
final NpcHtmlMessage msg = new NpcHtmlMessage();

View File

@@ -68,7 +68,7 @@ public class Debug implements ITelnetCommand
@Override
public String getUsage()
{
return "Debug <decay/packetsend/PacketTP/IOPacketTP/GeneralTP/full>";
return "Debug <decay/packetsend/full>";
}
@Override
@@ -108,90 +108,6 @@ public class Debug implements ITelnetCommand
player.sendPacket(sp);
return "Packet has been sent!";
}
case "PacketTP":
{
final String str = ThreadPoolManager.getInstance().getPacketStats();
int i = 0;
File f = new File("./log/StackTrace-PacketTP-" + i + ".txt");
while (f.exists())
{
i++;
f = new File("./log/StackTrace-PacketTP-" + i + ".txt");
}
f.getParentFile().mkdirs();
try
{
Files.write(f.toPath(), str.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE);
}
catch (IOException e)
{
LOGGER.log(Level.WARNING, "Couldn't write packet tp.", e);
}
return str;
}
case "IOPacketTP":
{
final String str = ThreadPoolManager.getInstance().getIOPacketStats();
int i = 0;
File f = new File("./log/StackTrace-IOPacketTP-" + i + ".txt");
while (f.exists())
{
i++;
f = new File("./log/StackTrace-IOPacketTP-" + i + ".txt");
}
f.getParentFile().mkdirs();
try
{
Files.write(f.toPath(), str.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE);
}
catch (IOException e)
{
LOGGER.log(Level.WARNING, "Couldn't write packet tp.", e);
}
return str;
}
case "GeneralTP":
{
final String str = ThreadPoolManager.getInstance().getGeneralStats();
int i = 0;
File f = new File("./log/StackTrace-GeneralTP-" + i + ".txt");
while (f.exists())
{
i++;
f = new File("./log/StackTrace-GeneralTP-" + i + ".txt");
}
f.getParentFile().mkdirs();
try
{
Files.write(f.toPath(), str.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE);
}
catch (IOException e)
{
LOGGER.log(Level.WARNING, "Couldn't write packet tp.", e);
}
return str;
}
case "GeneralScheduledTP":
{
final String str = ThreadPoolManager.getInstance().getGeneralStats();
int i = 0;
File f = new File("./log/StackTrace-GeneralScheduledTP-" + i + ".txt");
while (f.exists())
{
i++;
f = new File("./log/StackTrace-GeneralScheduledTP-" + i + ".txt");
}
f.getParentFile().mkdirs();
try
{
Files.write(f.toPath(), str.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE);
}
catch (IOException e)
{
LOGGER.log(Level.WARNING, "Couldn't write packet tp.", e);
}
return str;
}
case "full":
{
final Calendar cal = Calendar.getInstance();
@@ -283,7 +199,7 @@ public class Debug implements ITelnetCommand
}
sb.append("\r\n## Thread Pool Manager Statistics ##\r\n");
for (String line : ThreadPoolManager.getInstance().getStats())
for (String line : ThreadPoolManager.getStats())
{
sb.append(line);
sb.append("\r\n");

View File

@@ -42,9 +42,9 @@ public class Performance implements ITelnetCommand
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
ThreadPoolManager.getInstance().purge();
// ThreadPoolManager.purge();
final StringBuilder sb = new StringBuilder();
for (String line : ThreadPoolManager.getInstance().getStats())
for (String line : ThreadPoolManager.getStats())
{
sb.append(line + Config.EOL);
}

View File

@@ -42,9 +42,9 @@ public class Purge implements ITelnetCommand
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
ThreadPoolManager.getInstance().purge();
ThreadPoolManager.purge();
final StringBuilder sb = new StringBuilder("STATUS OF THREAD POOLS AFTER PURGE COMMAND:" + Config.EOL);
for (String line : ThreadPoolManager.getInstance().getStats())
for (String line : ThreadPoolManager.getStats())
{
sb.append(line + Config.EOL);
}

View File

@@ -1,171 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.telnethandlers.server;
import java.lang.reflect.Field;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.FutureTask;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.ThreadPoolManager.RunnableWrapper;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class ThreadPoolDebug implements ITelnetCommand
{
private static final Logger LOGGER = Logger.getLogger(ThreadPoolDebug.class.getName());
@Override
public String getCommand()
{
return "threadpooldebug";
}
@Override
public String getUsage()
{
return "threadpooldebug [effect, general, ai, events]";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
String pool = "_generalScheduledThreadPool";
if (args.length > 0)
{
switch (args[0])
{
case "effect":
{
pool = "_effectsScheduledThreadPool";
break;
}
case "general":
{
pool = "_generalScheduledThreadPool";
break;
}
case "ai":
{
pool = "_aiScheduledThreadPool";
break;
}
case "events":
{
pool = "_eventScheduledThreadPool";
break;
}
default:
{
return args[0] + " is not implemented!";
}
}
}
final ScheduledThreadPoolExecutor executor = getObject(ThreadPoolManager.class, ThreadPoolManager.getInstance(), pool, ScheduledThreadPoolExecutor.class);
if (executor == null)
{
return "Couldn't retreive " + pool + "!";
}
Class<?> adapterClass;
try
{
adapterClass = Class.forName("java.util.concurrent.Executors$RunnableAdapter");
}
catch (Exception e)
{
return e.getMessage();
}
final Map<String, Integer> tasks = new HashMap<>();
for (Runnable run : executor.getQueue())
{
try
{
if (run instanceof FutureTask)
{
final Object callableObject = getObject(FutureTask.class, run, "callable", Object.class);
final Object taskObject = getObject(adapterClass, callableObject, "task", Object.class);
if (taskObject instanceof RunnableWrapper)
{
final Runnable task = getObject(RunnableWrapper.class, taskObject, "_r", Runnable.class);
final String name = task.getClass().getName();
final int times = tasks.containsKey(name) ? tasks.get(name) : 0;
tasks.put(name, times + 1);
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
final StringBuilder sb = new StringBuilder();
sb.append(pool + " queue size: " + executor.getQueue().size() + Config.EOL);
tasks.entrySet().stream().sorted(Comparator.comparingInt(Entry::getValue)).forEach(entry -> sb.append("Class: " + entry.getKey() + " = " + entry.getValue() + Config.EOL));
return sb.toString();
}
private static <T> T getObject(Class<?> sourceClass, Object sourceInstance, String fieldName, Class<T> targetClass)
{
try
{
final Field field = sourceClass.getDeclaredField(fieldName);
// Mark down if field was accessible
final boolean isAccessible = field.isAccessible();
// Enforce accessible to retrieve the object associated with this field
if (!isAccessible)
{
field.setAccessible(true);
}
// Get the object
final Object fieldObject = field.get(sourceInstance);
// Restore the original accessible state.
field.setAccessible(isAccessible);
// Make sure the object is the one we expect to be
if (targetClass.isInstance(fieldObject))
{
return targetClass.cast(fieldObject);
}
}
catch (Exception e)
{
LOGGER.log(Level.WARNING, "Error while retrieving object of " + sourceInstance.getClass().getName() + "." + fieldName, e);
}
return null;
}
}

View File

@@ -22,7 +22,6 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.ThreadPoolManager;
@@ -203,7 +202,7 @@ public final class CastleDungeon extends AbstractInstance
*/
private void spawnRaid(Instance instance)
{
final ScheduledFuture<?> spawnTask = ThreadPoolManager.getInstance().scheduleGeneral(() ->
final ScheduledFuture<?> spawnTask = ThreadPoolManager.schedule(() ->
{
// Get template id of raid
final int npcId;
@@ -230,7 +229,7 @@ public final class CastleDungeon extends AbstractInstance
// Unset spawn task reference
instance.setParameter("spawnTask", null);
}, 2, TimeUnit.MINUTES);
}, 2 * 60 * 1000); // 2 minutes
// Save timer to instance world
instance.setParameter("spawnTask", spawnTask);

View File

@@ -111,7 +111,7 @@ public final class ChamberOfDelusion extends AbstractInstance
changeRoom(instance);
// Start banish task
final ScheduledFuture<?> banishTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(() ->
final ScheduledFuture<?> banishTask = ThreadPoolManager.scheduleAtFixedRate(() ->
{
if (instance.getRemainingTime() < 60000)
{
@@ -410,7 +410,7 @@ public final class ChamberOfDelusion extends AbstractInstance
final long nextInterval = (bossRoom) ? 60000L : (ROOM_CHANGE_INTERVAL + getRandom(ROOM_CHANGE_RANDOM_TIME)) * 1000L;
if (world.getRemainingTime() > nextInterval)
{
final ScheduledFuture<?> roomChangeTask = ThreadPoolManager.getInstance().scheduleGeneral(() ->
final ScheduledFuture<?> roomChangeTask = ThreadPoolManager.schedule(() ->
{
try
{

View File

@@ -22,7 +22,6 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.ThreadPoolManager;
@@ -226,7 +225,7 @@ public final class FortressDungeon extends AbstractInstance
*/
private void spawnRaid(Instance instance)
{
final ScheduledFuture<?> spawnTask = ThreadPoolManager.getInstance().scheduleGeneral(() ->
final ScheduledFuture<?> spawnTask = ThreadPoolManager.schedule(() ->
{
// Get template id of raid
final int npcId;
@@ -247,7 +246,7 @@ public final class FortressDungeon extends AbstractInstance
// Unset spawn task reference
instance.setParameter("spawnTask", null);
}, 2, TimeUnit.MINUTES);
}, 2 * 60 * 1000); // 2 minutes
// Save timer to instance world
instance.setParameter("spawnTask", spawnTask);

View File

@@ -168,7 +168,7 @@ public final class Q10292_SevenSignsGirlOfDoubt extends Quest
creature1.setRandomWalking(true);
final L2Npc creature2 = addSpawn(CREATURE_OF_THE_DUSK2, 89524, -238131, -9632, 56, false, 0, false, player.getInstanceId());
creature2.setRandomWalking(true);
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
creature1.deleteMe();
creature2.deleteMe();

View File

@@ -291,11 +291,11 @@ public abstract class AirShipController extends AbstractNpcAI
playMovie(_dockedShip.getPassengers(), _movie);
}
ThreadPoolManager.getInstance().scheduleGeneral(_decayTask, 1000);
ThreadPoolManager.schedule(_decayTask, 1000);
}
else
{
_departSchedule = ThreadPoolManager.getInstance().scheduleGeneral(_departTask, DEPART_INTERVAL);
_departSchedule = ThreadPoolManager.schedule(_departTask, DEPART_INTERVAL);
}
}
}

View File

@@ -248,7 +248,7 @@ public final class AirShipGludioGracia extends AbstractNpcAI implements Runnable
case 1:
// _ship.teleToLocation(-167874, 256731, -509, 41035, false);
_ship.setOustLoc(OUST_GRACIA);
ThreadPoolManager.getInstance().scheduleGeneral(this, 5000);
ThreadPoolManager.schedule(this, 5000);
break;
case 2:
_ship.executePath(WARPGATE_TO_GRACIA);
@@ -257,7 +257,7 @@ public final class AirShipGludioGracia extends AbstractNpcAI implements Runnable
broadcastInGracia(NpcStringId.THE_REGULARLY_SCHEDULED_AIRSHIP_HAS_ARRIVED_IT_WILL_DEPART_FOR_THE_ADEN_CONTINENT_IN_1_MINUTE);
_ship.setInDock(GRACIA_DOCK_ID);
_ship.oustPlayers();
ThreadPoolManager.getInstance().scheduleGeneral(this, 60000);
ThreadPoolManager.schedule(this, 60000);
break;
case 4:
broadcastInGracia(NpcStringId.THE_REGULARLY_SCHEDULED_AIRSHIP_THAT_FLIES_TO_THE_ADEN_CONTINENT_HAS_DEPARTED);
@@ -267,7 +267,7 @@ public final class AirShipGludioGracia extends AbstractNpcAI implements Runnable
case 5:
// _ship.teleToLocation(-157261, 255664, 221, 64781, false);
_ship.setOustLoc(OUST_GLUDIO);
ThreadPoolManager.getInstance().scheduleGeneral(this, 5000);
ThreadPoolManager.schedule(this, 5000);
break;
case 6:
_ship.executePath(WARPGATE_TO_GLUDIO);
@@ -276,7 +276,7 @@ public final class AirShipGludioGracia extends AbstractNpcAI implements Runnable
broadcastInGludio(NpcStringId.THE_REGULARLY_SCHEDULED_AIRSHIP_HAS_ARRIVED_IT_WILL_DEPART_FOR_THE_GRACIA_CONTINENT_IN_1_MINUTE);
_ship.setInDock(GLUDIO_DOCK_ID);
_ship.oustPlayers();
ThreadPoolManager.getInstance().scheduleGeneral(this, 60000);
ThreadPoolManager.schedule(this, 60000);
break;
}
_cycle++;

View File

@@ -175,15 +175,15 @@ public class BoatGludinRune implements Runnable
{
case 0:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], LEAVE_GLUDIN5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 1:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], LEAVE_GLUDIN1);
ThreadPoolManager.getInstance().scheduleGeneral(this, 40000);
ThreadPoolManager.schedule(this, 40000);
break;
case 2:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], LEAVE_GLUDIN0);
ThreadPoolManager.getInstance().scheduleGeneral(this, 20000);
ThreadPoolManager.schedule(this, 20000);
break;
case 3:
BoatManager.getInstance().dockShip(BoatManager.GLUDIN_HARBOR, false);
@@ -191,19 +191,19 @@ public class BoatGludinRune implements Runnable
_boat.broadcastPacket(GLUDIN_SOUND);
_boat.payForRide(7905, 1, -90015, 150422, -3610);
_boat.executePath(GLUDIN_TO_RUNE);
ThreadPoolManager.getInstance().scheduleGeneral(this, 250000);
ThreadPoolManager.schedule(this, 250000);
break;
case 4:
BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], ARRIVAL_RUNE15);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 5:
BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], ARRIVAL_RUNE10);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 6:
BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], ARRIVAL_RUNE5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 7:
BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], ARRIVAL_RUNE1);
@@ -222,7 +222,7 @@ public class BoatGludinRune implements Runnable
_shoutCount = 0;
}
ThreadPoolManager.getInstance().scheduleGeneral(this, 5000);
ThreadPoolManager.schedule(this, 5000);
return;
}
_boat.executePath(RUNE_DOCK);
@@ -231,19 +231,19 @@ public class BoatGludinRune implements Runnable
BoatManager.getInstance().dockShip(BoatManager.RUNE_HARBOR, true);
BoatManager.getInstance().broadcastPackets(RUNE_DOCK[0], GLUDIN_DOCK[0], ARRIVED_AT_RUNE, ARRIVED_AT_RUNE_2);
_boat.broadcastPacket(RUNE_SOUND);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 10:
BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], LEAVE_RUNE5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 11:
BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], LEAVE_RUNE1);
ThreadPoolManager.getInstance().scheduleGeneral(this, 40000);
ThreadPoolManager.schedule(this, 40000);
break;
case 12:
BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], LEAVE_RUNE0);
ThreadPoolManager.getInstance().scheduleGeneral(this, 20000);
ThreadPoolManager.schedule(this, 20000);
break;
case 13:
BoatManager.getInstance().dockShip(BoatManager.RUNE_HARBOR, false);
@@ -251,19 +251,19 @@ public class BoatGludinRune implements Runnable
_boat.broadcastPacket(RUNE_SOUND);
_boat.payForRide(7904, 1, 34513, -38009, -3640);
_boat.executePath(RUNE_TO_GLUDIN);
ThreadPoolManager.getInstance().scheduleGeneral(this, 60000);
ThreadPoolManager.schedule(this, 60000);
break;
case 14:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], ARRIVAL_GLUDIN15);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 15:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], ARRIVAL_GLUDIN10);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 16:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], ARRIVAL_GLUDIN5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 17:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], ARRIVAL_GLUDIN1);
@@ -282,7 +282,7 @@ public class BoatGludinRune implements Runnable
_shoutCount = 0;
}
ThreadPoolManager.getInstance().scheduleGeneral(this, 5000);
ThreadPoolManager.schedule(this, 5000);
return;
}
_boat.executePath(GLUDIN_DOCK);
@@ -291,7 +291,7 @@ public class BoatGludinRune implements Runnable
BoatManager.getInstance().dockShip(BoatManager.GLUDIN_HARBOR, true);
BoatManager.getInstance().broadcastPackets(GLUDIN_DOCK[0], RUNE_DOCK[0], ARRIVED_AT_GLUDIN, ARRIVED_AT_GLUDIN_2);
_boat.broadcastPacket(GLUDIN_SOUND);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
}
_shoutCount = 0;

View File

@@ -118,44 +118,44 @@ public class BoatInnadrilTour implements Runnable
{
case 0:
BoatManager.getInstance().broadcastPacket(DOCK, DOCK, LEAVE_INNADRIL5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 1:
BoatManager.getInstance().broadcastPacket(DOCK, DOCK, LEAVE_INNADRIL1);
ThreadPoolManager.getInstance().scheduleGeneral(this, 40000);
ThreadPoolManager.schedule(this, 40000);
break;
case 2:
BoatManager.getInstance().broadcastPacket(DOCK, DOCK, LEAVE_INNADRIL0);
ThreadPoolManager.getInstance().scheduleGeneral(this, 20000);
ThreadPoolManager.schedule(this, 20000);
break;
case 3:
BoatManager.getInstance().broadcastPackets(DOCK, DOCK, LEAVING_INNADRIL, INNADRIL_SOUND);
_boat.payForRide(0, 1, 107092, 219098, -3952);
_boat.executePath(TOUR);
ThreadPoolManager.getInstance().scheduleGeneral(this, 650000);
ThreadPoolManager.schedule(this, 650000);
break;
case 4:
BoatManager.getInstance().broadcastPacket(DOCK, DOCK, ARRIVAL20);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 5:
BoatManager.getInstance().broadcastPacket(DOCK, DOCK, ARRIVAL15);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 6:
BoatManager.getInstance().broadcastPacket(DOCK, DOCK, ARRIVAL10);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 7:
BoatManager.getInstance().broadcastPacket(DOCK, DOCK, ARRIVAL5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 8:
BoatManager.getInstance().broadcastPacket(DOCK, DOCK, ARRIVAL1);
break;
case 9:
BoatManager.getInstance().broadcastPackets(DOCK, DOCK, ARRIVED_AT_INNADRIL, INNADRIL_SOUND);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
}
_cycle++;

View File

@@ -117,7 +117,7 @@ public class BoatRunePrimeval implements Runnable
break;
case 1:
BoatManager.getInstance().broadcastPackets(PRIMEVAL_DOCK, RUNE_DOCK[0], ARRIVED_AT_PRIMEVAL, ARRIVED_AT_PRIMEVAL_2, PRIMEVAL_SOUND);
ThreadPoolManager.getInstance().scheduleGeneral(this, 180000);
ThreadPoolManager.schedule(this, 180000);
break;
case 2:
BoatManager.getInstance().broadcastPackets(PRIMEVAL_DOCK, RUNE_DOCK[0], LEAVING_PRIMEVAL, PRIMEVAL_SOUND);
@@ -138,7 +138,7 @@ public class BoatRunePrimeval implements Runnable
_shoutCount = 0;
}
ThreadPoolManager.getInstance().scheduleGeneral(this, 5000);
ThreadPoolManager.schedule(this, 5000);
return;
}
_boat.executePath(RUNE_DOCK);
@@ -146,7 +146,7 @@ public class BoatRunePrimeval implements Runnable
case 4:
BoatManager.getInstance().dockShip(BoatManager.RUNE_HARBOR, true);
BoatManager.getInstance().broadcastPackets(RUNE_DOCK[0], PRIMEVAL_DOCK, ARRIVED_AT_RUNE, ARRIVED_AT_RUNE_2, RUNE_SOUND);
ThreadPoolManager.getInstance().scheduleGeneral(this, 180000);
ThreadPoolManager.schedule(this, 180000);
break;
}
_shoutCount = 0;

View File

@@ -426,14 +426,11 @@ public final class Config
public static boolean ALT_DEV_NO_SPAWNS;
public static boolean ALT_DEV_SHOW_QUESTS_LOAD_IN_LOGS;
public static boolean ALT_DEV_SHOW_SCRIPTS_LOAD_IN_LOGS;
public static int THREAD_P_EFFECTS;
public static int THREAD_P_GENERAL;
public static int THREAD_E_EVENTS;
public static int GENERAL_PACKET_THREAD_CORE_SIZE;
public static int SCHEDULED_THREAD_POOL_COUNT;
public static int THREADS_PER_SCHEDULED_THREAD_POOL;
public static int INSTANT_THREAD_POOL_COUNT;
public static int THREADS_PER_INSTANT_THREAD_POOL;
public static int IO_PACKET_THREAD_CORE_SIZE;
public static int GENERAL_THREAD_CORE_SIZE;
public static int AI_MAX_THREAD;
public static int EVENT_MAX_THREAD;
public static boolean DEADLOCK_DETECTOR;
public static int DEADLOCK_CHECK_INTERVAL;
public static boolean RESTART_ON_DEADLOCK;
@@ -1705,14 +1702,11 @@ public final class Config
ALT_DEV_NO_SPAWNS = General.getBoolean("AltDevNoSpawns", false) || Boolean.getBoolean("nospawns");
ALT_DEV_SHOW_QUESTS_LOAD_IN_LOGS = General.getBoolean("AltDevShowQuestsLoadInLogs", false);
ALT_DEV_SHOW_SCRIPTS_LOAD_IN_LOGS = General.getBoolean("AltDevShowScriptsLoadInLogs", false);
THREAD_P_EFFECTS = General.getInt("ThreadPoolSizeEffects", 10);
THREAD_P_GENERAL = General.getInt("ThreadPoolSizeGeneral", 13);
THREAD_E_EVENTS = General.getInt("ThreadPoolSizeEvents", 2);
SCHEDULED_THREAD_POOL_COUNT = General.getInt("ScheduledThreadPoolCount", -1);
THREADS_PER_SCHEDULED_THREAD_POOL = General.getInt("ThreadsPerScheduledThreadPool", 4);
INSTANT_THREAD_POOL_COUNT = General.getInt("InstantThreadPoolCount", -1);
THREADS_PER_INSTANT_THREAD_POOL = General.getInt("ThreadsPerInstantThreadPool", 2);
IO_PACKET_THREAD_CORE_SIZE = General.getInt("UrgentPacketThreadCoreSize", 2);
GENERAL_PACKET_THREAD_CORE_SIZE = General.getInt("GeneralPacketThreadCoreSize", 4);
GENERAL_THREAD_CORE_SIZE = General.getInt("GeneralThreadCoreSize", 4);
AI_MAX_THREAD = General.getInt("AiMaxThread", 6);
EVENT_MAX_THREAD = General.getInt("EventsMaxThread", 5);
DEADLOCK_DETECTOR = General.getBoolean("DeadLockDetector", true);
DEADLOCK_CHECK_INTERVAL = General.getInt("DeadLockCheckInterval", 20);
RESTART_ON_DEADLOCK = General.getBoolean("RestartOnDeadlock", false);

View File

@@ -176,13 +176,15 @@ public class GameServer
{
final long serverLoadStart = System.currentTimeMillis();
printSection("IdFactory");
if (!IdFactory.getInstance().isInitialized())
{
LOGGER.severe(getClass().getSimpleName() + ": Could not read object IDs from database. Please check your configuration.");
throw new Exception("Could not initialize the ID factory");
}
ThreadPoolManager.getInstance();
printSection("ThreadPool");
ThreadPoolManager.init();
EventDispatcher.getInstance();
// load script engines
@@ -477,7 +479,6 @@ public class GameServer
// Initialize config
Config.load();
printSection("Database");
DatabaseFactory.getInstance();
INSTANCE = new GameServer();

View File

@@ -31,7 +31,7 @@ public final class ItemsAutoDestroy
protected ItemsAutoDestroy()
{
ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(this::removeItems, 5000, 5000);
ThreadPoolManager.scheduleAtFixedRate(this::removeItems, 5000, 5000);
}
public static ItemsAutoDestroy getInstance()

View File

@@ -109,7 +109,7 @@ public class RecipeController
if (Config.ALT_GAME_CREATION)
{
_activeMakers.put(manufacturer.getObjectId(), maker);
ThreadPoolManager.getInstance().scheduleGeneral(maker, 100);
ThreadPoolManager.schedule(maker, 100);
}
else
{
@@ -158,7 +158,7 @@ public class RecipeController
if (Config.ALT_GAME_CREATION)
{
_activeMakers.put(player.getObjectId(), maker);
ThreadPoolManager.getInstance().scheduleGeneral(maker, 100);
ThreadPoolManager.schedule(maker, 100);
}
else
{
@@ -354,7 +354,7 @@ public class RecipeController
_player.broadcastPacket(msk);
_player.sendPacket(new SetupGauge(_player.getObjectId(), 0, _delay));
ThreadPoolManager.getInstance().scheduleGeneral(this, 100 + _delay);
ThreadPoolManager.schedule(this, 100 + _delay);
}
else
{
@@ -548,7 +548,7 @@ public class RecipeController
if (Config.ALT_GAME_CREATION && isWait)
{
_player.sendPacket(new SetupGauge(_player.getObjectId(), 0, _delay));
ThreadPoolManager.getInstance().scheduleGeneral(this, 100 + _delay);
ThreadPoolManager.schedule(this, 100 + _delay);
}
else
{
@@ -570,7 +570,7 @@ public class RecipeController
if (Config.ALT_GAME_CREATION && isWait)
{
_player.sendPacket(new SetupGauge(_player.getObjectId(), 0, _delay));
ThreadPoolManager.getInstance().scheduleGeneral(this, 100 + _delay);
ThreadPoolManager.schedule(this, 100 + _delay);
}
else
{

View File

@@ -215,7 +215,7 @@ public class Shutdown extends Thread
// stop all thread pools
try
{
ThreadPoolManager.getInstance().shutdown();
ThreadPoolManager.shutdown();
LOGGER.info("Thread Pool Manager: Manager has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
}
catch (Throwable t)

View File

@@ -728,7 +728,7 @@ public abstract class AbstractAI implements Ctrl
setTarget(target);
final int followRange = range == -1 ? Rnd.get(50, 100) : range;
_followTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(() ->
_followTask = ThreadPoolManager.scheduleAtFixedRate(() ->
{
try
{

View File

@@ -203,7 +203,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
// If not idle - create an AI task (schedule onEvtThink repeatedly)
if (_aiTask == null)
{
_aiTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(this, 1000, 1000);
_aiTask = ThreadPoolManager.scheduleAtFixedRate(this, 1000, 1000);
}
}

View File

@@ -308,7 +308,7 @@ public class L2CharacterAI extends AbstractAI
if (_actor.isAttackingNow())
{
ThreadPoolManager.getInstance().scheduleGeneral(new CastTask(_actor, skill, target, item, forceUse, dontMove), _actor.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis()));
ThreadPoolManager.schedule(new CastTask(_actor, skill, target, item, forceUse, dontMove), _actor.getAttackEndTime() - TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis()));
}
else
{

View File

@@ -89,7 +89,7 @@ public class L2DoorAI extends L2CharacterAI
@Override
protected void onEvtAttacked(L2Character attacker)
{
ThreadPoolManager.getInstance().executeGeneral(new onEventAttackedDoorTask((L2DoorInstance) _actor, attacker));
ThreadPoolManager.execute(new onEventAttackedDoorTask((L2DoorInstance) _actor, attacker));
}
@Override

View File

@@ -217,7 +217,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
// If not idle - create an AI task (schedule onEvtThink repeatedly)
if (_aiTask == null)
{
_aiTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(this, 1000, 1000);
_aiTask = ThreadPoolManager.scheduleAtFixedRate(this, 1000, 1000);
}
}

View File

@@ -204,7 +204,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
// If not idle - create an AI task (schedule onEvtThink repeatedly)
if (_aiTask == null)
{
_aiTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(this, 1000, 1000);
_aiTask = ThreadPoolManager.scheduleAtFixedRate(this, 1000, 1000);
}
}

View File

@@ -342,7 +342,7 @@ public class L2SummonAI extends L2PlayableAI implements Runnable
{
if (_avoidTask == null)
{
_avoidTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(this, 100, 100);
_avoidTask = ThreadPoolManager.scheduleAtFixedRate(this, 100, 100);
}
}

View File

@@ -33,7 +33,7 @@ public class WarehouseCacheManager
protected WarehouseCacheManager()
{
ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new CacheScheduler(), 120000, 60000);
ThreadPoolManager.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000);
}
public void addCacheTask(L2PcInstance pc)

View File

@@ -331,7 +331,7 @@ public class ClanTable
public void scheduleRemoveClan(int clanId)
{
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
if (getClan(clanId) == null)
{

View File

@@ -421,11 +421,11 @@ public final class BotReportTable
c.set(Calendar.DAY_OF_YEAR, c.get(Calendar.DAY_OF_YEAR) + 1);
}
ThreadPoolManager.getInstance().scheduleGeneral(new ResetPointTask(), c.getTimeInMillis() - System.currentTimeMillis());
ThreadPoolManager.schedule(new ResetPointTask(), c.getTimeInMillis() - System.currentTimeMillis());
}
catch (Exception e)
{
ThreadPoolManager.getInstance().scheduleGeneral(new ResetPointTask(), 24 * 3600 * 1000);
ThreadPoolManager.schedule(new ResetPointTask(), 24 * 3600 * 1000);
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not properly schedule bot report points reset task. Scheduled in 24 hours.", e);
}
}

View File

@@ -221,14 +221,14 @@ public class ItemTable
if ((raid.getFirstCommandChannelAttacked() != null) && !Config.AUTO_LOOT_RAIDS)
{
item.setOwnerId(raid.getFirstCommandChannelAttacked().getLeaderObjectId());
itemLootShedule = ThreadPoolManager.getInstance().scheduleGeneral(new ResetOwner(item), Config.LOOT_RAIDS_PRIVILEGE_INTERVAL);
itemLootShedule = ThreadPoolManager.schedule(new ResetOwner(item), Config.LOOT_RAIDS_PRIVILEGE_INTERVAL);
item.setItemLootShedule(itemLootShedule);
}
}
else if (!Config.AUTO_LOOT || ((reference instanceof L2EventMonsterInstance) && ((L2EventMonsterInstance) reference).eventDropOnGround()))
{
item.setOwnerId(actor.getObjectId());
itemLootShedule = ThreadPoolManager.getInstance().scheduleGeneral(new ResetOwner(item), 15000);
itemLootShedule = ThreadPoolManager.schedule(new ResetOwner(item), 15000);
item.setItemLootShedule(itemLootShedule);
}
}

View File

@@ -53,7 +53,7 @@ public class BitSetIDFactory extends IdFactory
synchronized (BitSetIDFactory.class)
{
ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new BitSetCapacityCheck(), 30000, 30000);
ThreadPoolManager.scheduleAtFixedRate(new BitSetCapacityCheck(), 30000, 30000);
initialize();
}
LOGGER.info(getClass().getSimpleName() + ": " + _freeIds.size() + " id's available.");

View File

@@ -29,7 +29,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
@@ -107,7 +106,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
// Schedule autosave
if (!Config.ALT_MANOR_SAVE_ALL_ACTIONS)
{
ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(this::storeMe, Config.ALT_MANOR_SAVE_PERIOD_RATE, Config.ALT_MANOR_SAVE_PERIOD_RATE, TimeUnit.HOURS);
ThreadPoolManager.scheduleAtFixedRate(this::storeMe, Config.ALT_MANOR_SAVE_PERIOD_RATE * 60 * 60 * 1000, Config.ALT_MANOR_SAVE_PERIOD_RATE * 60 * 60 * 1000);
}
// Send debug message
@@ -278,7 +277,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
break;
}
// Schedule mode change
ThreadPoolManager.getInstance().scheduleGeneral(this::changeMode, (_nextModeChange.getTimeInMillis() - System.currentTimeMillis()));
ThreadPoolManager.schedule(this::changeMode, (_nextModeChange.getTimeInMillis() - System.currentTimeMillis()));
}
public final void changeMode()

View File

@@ -390,7 +390,7 @@ public class ClanEntryManager
private static void lockPlayer(int playerId)
{
_playerLocked.put(playerId, ThreadPoolManager.getInstance().scheduleGeneral(() ->
_playerLocked.put(playerId, ThreadPoolManager.schedule(() ->
{
_playerLocked.remove(playerId);
}, LOCK_TIME));
@@ -398,7 +398,7 @@ public class ClanEntryManager
private static void lockClan(int clanId)
{
_clanLocked.put(clanId, ThreadPoolManager.getInstance().scheduleGeneral(() ->
_clanLocked.put(clanId, ThreadPoolManager.schedule(() ->
{
_clanLocked.remove(clanId);
}, LOCK_TIME));

View File

@@ -114,7 +114,7 @@ public final class CommissionManager
}
else
{
commissionItem.setSaleEndTask(ThreadPoolManager.getInstance().scheduleGeneral(() -> expireSale(commissionItem), Duration.between(Instant.now(), commissionItem.getEndTime()).toMillis()));
commissionItem.setSaleEndTask(ThreadPoolManager.schedule(() -> expireSale(commissionItem), Duration.between(Instant.now(), commissionItem.getEndTime()).toMillis()));
}
}
}
@@ -259,7 +259,7 @@ public final class CommissionManager
if (rs.next())
{
final CommissionItem commissionItem = new CommissionItem(rs.getLong(1), itemInstance, pricePerUnit, startTime, durationInDays);
final ScheduledFuture<?> saleEndTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> expireSale(commissionItem), Duration.between(Instant.now(), commissionItem.getEndTime()).toMillis());
final ScheduledFuture<?> saleEndTask = ThreadPoolManager.schedule(() -> expireSale(commissionItem), Duration.between(Instant.now(), commissionItem.getEndTime()).toMillis());
commissionItem.setSaleEndTask(saleEndTask);
_commissionItems.put(commissionItem.getCommissionId(), commissionItem);
player.getLastCommissionInfos().put(itemInstance.getId(), new ExResponseCommissionInfo(itemInstance.getId(), pricePerUnit, itemCount, (byte) ((durationInDays - 1) / 2)));

View File

@@ -226,7 +226,7 @@ public class DBSpawnManager
{
LOGGER.info(getClass().getSimpleName() + ": Updated " + npc.getName() + " respawn time to " + Util.formatDate(new Date(respawnTime), "dd.MM.yyyy HH:mm"));
_schedules.put(npc.getId(), ThreadPoolManager.getInstance().scheduleGeneral(new SpawnSchedule(npc.getId()), respawnDelay));
_schedules.put(npc.getId(), ThreadPoolManager.schedule(new SpawnSchedule(npc.getId()), respawnDelay));
updateDb();
}
}
@@ -287,7 +287,7 @@ public class DBSpawnManager
else
{
final long spawnTime = respawnTime - System.currentTimeMillis();
_schedules.put(npcId, ThreadPoolManager.getInstance().scheduleGeneral(new SpawnSchedule(npcId), spawnTime));
_schedules.put(npcId, ThreadPoolManager.schedule(new SpawnSchedule(npcId), spawnTime));
}
_spawns.put(npcId, spawn);

View File

@@ -101,7 +101,7 @@ public final class GraciaSeedsManager
}
else
{
ThreadPoolManager.getInstance().scheduleEffect(new UpdateSoDStateTask(), Config.SOD_STAGE_2_LENGTH - timePast);
ThreadPoolManager.schedule(new UpdateSoDStateTask(), Config.SOD_STAGE_2_LENGTH - timePast);
}
break;
case 3:

View File

@@ -98,7 +98,7 @@ public final class GrandBossManager implements IStorable
{
_log.log(Level.WARNING, getClass().getSimpleName() + ": Error while initializing GrandBossManager: " + e.getMessage(), e);
}
ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new GrandBossManagerStoreTask(), 5 * 60 * 1000, 5 * 60 * 1000);
ThreadPoolManager.scheduleAtFixedRate(new GrandBossManagerStoreTask(), 5 * 60 * 1000, 5 * 60 * 1000);
}
public int getBossStatus(int bossId)

View File

@@ -86,7 +86,7 @@ public final class HandysBlockCheckerManager
{
holder.checkAndShuffle();
}
ThreadPoolManager.getInstance().executeGeneral(holder.getEvent().new StartEvent());
ThreadPoolManager.execute(holder.getEvent().new StartEvent());
}
else
{
@@ -364,7 +364,7 @@ public final class HandysBlockCheckerManager
private void schedulePenaltyRemoval(int objId)
{
ThreadPoolManager.getInstance().scheduleGeneral(new PenaltyRemoveTask(objId), 10000);
ThreadPoolManager.schedule(new PenaltyRemoveTask(objId), 10000);
}
/**

View File

@@ -47,7 +47,7 @@ public final class ItemsOnGroundManager implements Runnable
{
if (Config.SAVE_DROPPED_ITEM_INTERVAL > 0)
{
ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(this, Config.SAVE_DROPPED_ITEM_INTERVAL, Config.SAVE_DROPPED_ITEM_INTERVAL);
ThreadPoolManager.scheduleAtFixedRate(this, Config.SAVE_DROPPED_ITEM_INTERVAL, Config.SAVE_DROPPED_ITEM_INTERVAL);
}
load();
}

View File

@@ -74,11 +74,11 @@ public final class MailManager
if (expiration < System.currentTimeMillis())
{
ThreadPoolManager.getInstance().scheduleGeneral(new MessageDeletionTask(msgId), 10000);
ThreadPoolManager.schedule(new MessageDeletionTask(msgId), 10000);
}
else
{
ThreadPoolManager.getInstance().scheduleGeneral(new MessageDeletionTask(msgId), expiration - System.currentTimeMillis());
ThreadPoolManager.schedule(new MessageDeletionTask(msgId), expiration - System.currentTimeMillis());
}
}
}
@@ -209,7 +209,7 @@ public final class MailManager
receiver.sendPacket(new ExUnReadMailCount(receiver));
}
ThreadPoolManager.getInstance().scheduleGeneral(new MessageDeletionTask(msg.getId()), msg.getExpiration() - System.currentTimeMillis());
ThreadPoolManager.schedule(new MessageDeletionTask(msg.getId()), msg.getExpiration() - System.currentTimeMillis());
}
public final void markAsReadInDb(int msgId)

View File

@@ -111,7 +111,7 @@ public class PremiumManager
*/
private void startExpireTask(L2PcInstance player, long delay)
{
ScheduledFuture<?> task = ThreadPoolManager.getInstance().scheduleEvent(new PremiumExpireTask(player), delay);
ScheduledFuture<?> task = ThreadPoolManager.schedule(new PremiumExpireTask(player), delay);
expiretasks.put(player.getAccountName(), task);
}

View File

@@ -71,7 +71,7 @@ public class ServerRestartManager
if (lastRestart != null)
{
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
ThreadPoolManager.getInstance().scheduleGeneral(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
ThreadPoolManager.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
_log.info("Scheduled server restart at " + lastRestart.getTime() + ".");
}
}

View File

@@ -301,14 +301,14 @@ public final class WalkingManager implements IGameXmlReader
npc.sendDebugMessage("Starting to move at route '" + routeName + "'");
npc.setIsRunning(node.runToLocation());
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, node);
walk.setWalkCheckTask(ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new StartMovingTask(npc, routeName), 60000, 60000)); // start walk check task, for resuming walk after fight
walk.setWalkCheckTask(ThreadPoolManager.scheduleAtFixedRate(new StartMovingTask(npc, routeName), 60000, 60000)); // start walk check task, for resuming walk after fight
_activeRoutes.put(npc.getObjectId(), walk); // register route
}
else
{
npc.sendDebugMessage("Failed to start moving along route '" + routeName + "', scheduled");
ThreadPoolManager.getInstance().scheduleGeneral(new StartMovingTask(npc, routeName), 60000);
ThreadPoolManager.schedule(new StartMovingTask(npc, routeName), 60000);
}
}
else
@@ -455,7 +455,7 @@ public final class WalkingManager implements IGameXmlReader
walk.setLastAction(System.currentTimeMillis());
}
ThreadPoolManager.getInstance().scheduleGeneral(new ArrivedTask(npc, walk), 100 + (node.getDelay() * 1000L));
ThreadPoolManager.schedule(new ArrivedTask(npc, walk), 100 + (node.getDelay() * 1000L));
}
}
}

View File

@@ -56,7 +56,7 @@ public final class ClanWar
_startTime = System.currentTimeMillis();
_state = ClanWarState.BLOOD_DECLARATION;
_cancelTask = ThreadPoolManager.getInstance().scheduleGeneral(() ->
_cancelTask = ThreadPoolManager.schedule(() ->
{
clanWarTimeout();
}, (_startTime + TIME_TO_CANCEL_NON_MUTUAL_CLAN_WAR) - System.currentTimeMillis());
@@ -88,7 +88,7 @@ public final class ClanWar
if ((_startTime + TIME_TO_CANCEL_NON_MUTUAL_CLAN_WAR) > System.currentTimeMillis())
{
_cancelTask = ThreadPoolManager.getInstance().scheduleGeneral(() ->
_cancelTask = ThreadPoolManager.schedule(() ->
{
clanWarTimeout();
}, (_startTime + TIME_TO_CANCEL_NON_MUTUAL_CLAN_WAR) - System.currentTimeMillis());
@@ -104,7 +104,7 @@ public final class ClanWar
}
else
{
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
ClanTable.getInstance().deleteclanswars(_attackerClanId, _attackedClanId);
}, endTimePeriod);
@@ -200,7 +200,7 @@ public final class ClanWar
_winnerClanId = winnerClan.getId();
_endTime = System.currentTimeMillis();
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
ClanTable.getInstance().deleteclanswars(cancelor.getId(), winnerClan.getId());
}, (_endTime + TIME_TO_DELETION_AFTER_DEFEAT) - System.currentTimeMillis());
@@ -225,7 +225,7 @@ public final class ClanWar
_state = ClanWarState.TIE;
_endTime = System.currentTimeMillis();
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
ClanTable.getInstance().deleteclanswars(attackerClan.getId(), attackedClan.getId());
}, (_endTime + TIME_TO_DELETION_AFTER_CANCELLATION) - System.currentTimeMillis());

View File

@@ -63,7 +63,7 @@ public class CreatureContainer
{
if ((_task == null) || _task.isDone())
{
_task = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(this::update, 1000L, 1000L);
_task = ThreadPoolManager.scheduleAtFixedRate(this::update, 1000L, 1000L);
}
}

View File

@@ -351,7 +351,7 @@ public class CursedWeapon implements INamable
{
_player.stopTransformation(true);
ThreadPoolManager.getInstance().scheduleGeneral(() -> _player.transform(transformationId, true), 500);
ThreadPoolManager.schedule(() -> _player.transform(transformationId, true), 500);
}
else
{
@@ -375,7 +375,7 @@ public class CursedWeapon implements INamable
}
else
{
_removeTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new RemoveTask(), _durationLost * 12000L, _durationLost * 12000L);
_removeTask = ThreadPoolManager.scheduleAtFixedRate(new RemoveTask(), _durationLost * 12000L, _durationLost * 12000L);
}
}
@@ -389,7 +389,7 @@ public class CursedWeapon implements INamable
// Start the Life Task
_endTime = System.currentTimeMillis() + (_duration * 60000L);
_removeTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new RemoveTask(), _durationLost * 12000L, _durationLost * 12000L);
_removeTask = ThreadPoolManager.scheduleAtFixedRate(new RemoveTask(), _durationLost * 12000L, _durationLost * 12000L);
return true;
}

View File

@@ -103,6 +103,6 @@ public class DropProtection implements Runnable
throw new NullPointerException("Trying to protect dropped item to null owner");
}
_task = ThreadPoolManager.getInstance().scheduleGeneral(this, PROTECTED_MILLIS_TIME);
_task = ThreadPoolManager.schedule(this, PROTECTED_MILLIS_TIME);
}
}

View File

@@ -220,10 +220,10 @@ public class Fishing
_player.rechargeShots(false, false, true);
}
_reelInTask = ThreadPoolManager.getInstance().scheduleGeneral(() ->
_reelInTask = ThreadPoolManager.schedule(() ->
{
_player.getFishing().reelInWithReward();
_startFishingTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> _player.getFishing().castLine(), Rnd.get(baitData.getWaitMin(), baitData.getWaitMax()));
_startFishingTask = ThreadPoolManager.schedule(() -> _player.getFishing().castLine(), Rnd.get(baitData.getWaitMin(), baitData.getWaitMax()));
}, Rnd.get(baitData.getTimeMin(), baitData.getTimeMax()));
_player.stopMove(null);
_player.broadcastPacket(new ExFishingStart(_player, -1, baitData.getLevel(), _baitLocation));

View File

@@ -3131,7 +3131,7 @@ public class L2Clan implements IIdentifiable, INamable
_vars = new ClanVariables(getId());
if (Config.CLAN_VARIABLES_STORE_INTERVAL > 0)
{
ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(this::storeVariables, Config.CLAN_VARIABLES_STORE_INTERVAL, Config.CLAN_VARIABLES_STORE_INTERVAL);
ThreadPoolManager.scheduleAtFixedRate(this::storeVariables, Config.CLAN_VARIABLES_STORE_INTERVAL, Config.CLAN_VARIABLES_STORE_INTERVAL);
}
}
}

View File

@@ -379,7 +379,7 @@ public class L2Party extends AbstractPlayerGroup
if (_positionBroadcastTask == null)
{
_positionBroadcastTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(() ->
_positionBroadcastTask = ThreadPoolManager.scheduleAtFixedRate(() ->
{
if (_positionPacket == null)
{
@@ -1084,7 +1084,7 @@ public class L2Party extends AbstractPlayerGroup
}
_changeRequestDistributionType = partyDistributionType;
_changeDistributionTypeAnswers = new HashSet<>();
_changeDistributionTypeRequestTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> finishLootRequest(false), PARTY_DISTRIBUTION_TYPE_REQUEST_TIMEOUT.toMillis());
_changeDistributionTypeRequestTask = ThreadPoolManager.schedule(() -> finishLootRequest(false), PARTY_DISTRIBUTION_TYPE_REQUEST_TIMEOUT.toMillis());
broadcastToPartyMembers(getLeader(), new ExAskModifyPartyLooting(getLeader().getName(), partyDistributionType));

View File

@@ -123,7 +123,7 @@ public class L2Request
{
_isRequestor = isRequestor;
_isAnswerer = !isRequestor;
ThreadPoolManager.getInstance().scheduleGeneral(() -> clear(), REQUEST_TIMEOUT * 1000);
ThreadPoolManager.schedule(() -> clear(), REQUEST_TIMEOUT * 1000);
}
/**

View File

@@ -400,7 +400,7 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
// Create a new SpawnTask to launch after the respawn Delay
// ClientScheduler.getInstance().scheduleLow(new SpawnTask(npcId), _respawnDelay);
ThreadPoolManager.getInstance().scheduleGeneral(new SpawnTask(oldNpc), hasRespawnRandom() ? Rnd.get(_respawnMinDelay, _respawnMaxDelay) : _respawnMinDelay);
ThreadPoolManager.schedule(new SpawnTask(oldNpc), hasRespawnRandom() ? Rnd.get(_respawnMinDelay, _respawnMaxDelay) : _respawnMinDelay);
}
}

View File

@@ -215,7 +215,7 @@ public final class L2WorldRegion
}
// then, set a timer to activate the neighbors
_neighborsTask = ThreadPoolManager.getInstance().scheduleGeneral(new NeighborsTask(true), 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
_neighborsTask = ThreadPoolManager.schedule(new NeighborsTask(true), 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
}
}
@@ -235,7 +235,7 @@ public final class L2WorldRegion
// start a timer to "suggest" a deactivate to self and neighbors.
// suggest means: first check if a neighbor has L2PcInstances in it. If not, deactivate.
_neighborsTask = ThreadPoolManager.getInstance().scheduleGeneral(new NeighborsTask(false), 1000 * Config.GRID_NEIGHBOR_TURNOFF_TIME);
_neighborsTask = ThreadPoolManager.schedule(new NeighborsTask(false), 1000 * Config.GRID_NEIGHBOR_TURNOFF_TIME);
}
}

View File

@@ -41,7 +41,7 @@ public class MpRewardTask
_creature = creature;
_count = new AtomicInteger(template.getMpRewardTicks());
_value = calculateBaseValue(npc, creature);
_task = ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
_task = ThreadPoolManager.scheduleAtFixedRate(this::run, Config.EFFECT_TICK_RATIO, Config.EFFECT_TICK_RATIO);
}
/**

View File

@@ -232,7 +232,7 @@ public class L2Attackable extends L2Npc
{
_commandChannelTimer = new CommandChannelTimer(this);
_commandChannelLastAttack = System.currentTimeMillis();
ThreadPoolManager.getInstance().scheduleGeneral(_commandChannelTimer, 10000); // check for last attack
ThreadPoolManager.schedule(_commandChannelTimer, 10000); // check for last attack
_firstCommandChannelAttacked.broadcastPacket(new CreatureSay(0, ChatType.PARTYROOM_ALL, "", "You have looting rights!")); // TODO: retail msg
}
}

View File

@@ -1100,7 +1100,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
if (getCurrentMp() < mpConsume)
{
// If L2PcInstance doesn't have enough MP, stop the attack
ThreadPoolManager.getInstance().scheduleAi(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), 1000);
ThreadPoolManager.schedule(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), 1000);
sendPacket(SystemMessageId.NOT_ENOUGH_MP);
sendPacket(ActionFailed.STATIC_PACKET);
return;
@@ -1118,7 +1118,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
else
{
// Cancel the action because the bow can't be re-use at this moment
ThreadPoolManager.getInstance().scheduleAi(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), 1000);
ThreadPoolManager.schedule(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), 1000);
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
@@ -1222,7 +1222,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
}
// Notify AI with EVT_READY_TO_ACT
ThreadPoolManager.getInstance().scheduleAi(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), timeAtk);
ThreadPoolManager.schedule(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), timeAtk);
}
}
@@ -1301,7 +1301,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
}
// Create a new hit task with Medium priority
ThreadPoolManager.getInstance().scheduleAi(new HitTask(this, target, damage1, crit1, miss1, attack.hasSoulshot(), shld1), sAtk);
ThreadPoolManager.schedule(new HitTask(this, target, damage1, crit1, miss1, attack.hasSoulshot(), shld1), sAtk);
// Calculate and set the disable delay of the bow in function of the Attack Speed
_disableRangedAttackEndTime = ((sAtk + reuse) / GameTimeController.MILLIS_IN_TICK) + GameTimeController.getInstance().getGameTicks();
@@ -1371,10 +1371,10 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
}
// Create a new hit task with Medium priority for hit 1
ThreadPoolManager.getInstance().scheduleAi(new HitTask(this, target, damage1, crit1, miss1, attack.hasSoulshot(), shld1), sAtk / 2);
ThreadPoolManager.schedule(new HitTask(this, target, damage1, crit1, miss1, attack.hasSoulshot(), shld1), sAtk / 2);
// Create a new hit task with Medium priority for hit 2 with a higher delay
ThreadPoolManager.getInstance().scheduleAi(new HitTask(this, target, damage2, crit2, miss2, attack.hasSoulshot(), shld2), sAtk);
ThreadPoolManager.schedule(new HitTask(this, target, damage2, crit2, miss2, attack.hasSoulshot(), shld2), sAtk);
// Add those hits to the Server-Client packet Attack
attack.addHit(target, damage1, miss1, crit1, shld1);
@@ -1401,7 +1401,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
damage /= 2;
}
ThreadPoolManager.getInstance().scheduleAi(new HitTask(this, surroundTarget, damage, crit, miss, attack.hasSoulshot(), shld), sAtk / 2);
ThreadPoolManager.schedule(new HitTask(this, surroundTarget, damage, crit, miss, attack.hasSoulshot(), shld), sAtk / 2);
attack.addHit(surroundTarget, damage, miss, crit, shld);
miss1 |= miss;
}
@@ -1421,7 +1421,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
damage /= 2;
}
ThreadPoolManager.getInstance().scheduleAi(new HitTask(this, surroundTarget, damage, crit, miss, attack.hasSoulshot(), shld), sAtk);
ThreadPoolManager.schedule(new HitTask(this, surroundTarget, damage, crit, miss, attack.hasSoulshot(), shld), sAtk);
attack.addHit(surroundTarget, damage, miss, crit, shld);
miss2 |= miss;
}
@@ -1471,7 +1471,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
}
// Create a new hit task with Medium priority
ThreadPoolManager.getInstance().scheduleAi(new HitTask(this, target, damage1, crit1, miss1, attack.hasSoulshot(), shld1), sAtk);
ThreadPoolManager.schedule(new HitTask(this, target, damage1, crit1, miss1, attack.hasSoulshot(), shld1), sAtk);
// Add this hit to the Server-Client packet Attack
attack.addHit(target, damage1, miss1, crit1, shld1);
@@ -1495,7 +1495,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
damage = (int) Formulas.calcAutoAttackDamage(this, surroundTarget, 0, shld, crit, attack.hasSoulshot());
}
ThreadPoolManager.getInstance().scheduleAi(new HitTask(this, surroundTarget, damage, crit, miss, attack.hasSoulshot(), shld), sAtk);
ThreadPoolManager.schedule(new HitTask(this, surroundTarget, damage, crit, miss, attack.hasSoulshot(), shld), sAtk);
attack.addHit(surroundTarget, damage, miss, crit, shld);
miss1 |= miss;
}
@@ -3332,7 +3332,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
if (distFraction > 1)
{
ThreadPoolManager.getInstance().executeAi(() -> getAI().notifyEvent(CtrlEvent.EVT_ARRIVED));
ThreadPoolManager.execute(() -> getAI().notifyEvent(CtrlEvent.EVT_ARRIVED));
return true;
}
@@ -3773,7 +3773,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
// Create a task to notify the AI that L2Character arrives at a check point of the movement
if ((ticksToMove * GameTimeController.MILLIS_IN_TICK) > 3000)
{
ThreadPoolManager.getInstance().scheduleAi(new NotifyAITask(this, CtrlEvent.EVT_ARRIVED_REVALIDATE), 2000);
ThreadPoolManager.schedule(new NotifyAITask(this, CtrlEvent.EVT_ARRIVED_REVALIDATE), 2000);
}
// the CtrlEvent.EVT_ARRIVED will be sent when the character will actually arrive
@@ -3854,7 +3854,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
// Create a task to notify the AI that L2Character arrives at a check point of the movement
if ((ticksToMove * GameTimeController.MILLIS_IN_TICK) > 3000)
{
ThreadPoolManager.getInstance().scheduleAi(new NotifyAITask(this, CtrlEvent.EVT_ARRIVED_REVALIDATE), 2000);
ThreadPoolManager.schedule(new NotifyAITask(this, CtrlEvent.EVT_ARRIVED_REVALIDATE), 2000);
}
// the CtrlEvent.EVT_ARRIVED will be sent when the character will actually arrive

View File

@@ -1216,7 +1216,7 @@ public class L2Npc extends L2Character
public void scheduleDespawn(long delay)
{
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
if (!isDecayed())
{

View File

@@ -87,7 +87,7 @@ public abstract class L2Vehicle extends L2Character
{
if (_engine != null)
{
ThreadPoolManager.getInstance().scheduleGeneral(_engine, delay);
ThreadPoolManager.schedule(_engine, delay);
}
}

View File

@@ -253,8 +253,8 @@ public class L2ControllableAirShipInstance extends L2AirShipInstance
public void onSpawn()
{
super.onSpawn();
_checkTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new CheckTask(), 60000, 10000);
_consumeFuelTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new ConsumeFuelTask(), 60000, 60000);
_checkTask = ThreadPoolManager.scheduleAtFixedRate(new CheckTask(), 60000, 10000);
_consumeFuelTask = ThreadPoolManager.scheduleAtFixedRate(new ConsumeFuelTask(), 60000, 60000);
}
@Override
@@ -326,7 +326,7 @@ public class L2ControllableAirShipInstance extends L2AirShipInstance
if (isSpawned() && isEmpty() && !isInDock())
{
// deleteMe() can't be called from CheckTask because task should not cancel itself
ThreadPoolManager.getInstance().executeGeneral(new DecayTask());
ThreadPoolManager.execute(new DecayTask());
}
}
}

View File

@@ -53,8 +53,8 @@ public class L2DecoyInstance extends L2Character
_totalLifeTime = totalLifeTime;
_timeRemaining = _totalLifeTime;
final int skilllevel = getTemplate().getDisplayId() - 13070;
_DecoyLifeTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new DecoyLifetime(getOwner(), this), 1000, 1000);
_HateSpam = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new HateSpam(this, SkillData.getInstance().getSkill(5272, skilllevel)), 2000, 5000);
_DecoyLifeTask = ThreadPoolManager.scheduleAtFixedRate(new DecoyLifetime(getOwner(), this), 1000, 1000);
_HateSpam = ThreadPoolManager.scheduleAtFixedRate(new HateSpam(this, SkillData.getInstance().getSkill(5272, skilllevel)), 2000, 5000);
}
@Override

View File

@@ -107,7 +107,7 @@ public final class L2DoorInstance extends L2Character
{
delay += Rnd.get(getTemplate().getRandomTime());
}
ThreadPoolManager.getInstance().scheduleGeneral(new TimerOpen(), delay * 1000);
ThreadPoolManager.schedule(new TimerOpen(), delay * 1000);
}
@Override
@@ -646,7 +646,7 @@ public final class L2DoorInstance extends L2Character
_autoCloseTask = null;
oldTask.cancel(false);
}
_autoCloseTask = ThreadPoolManager.getInstance().scheduleGeneral(new AutoClose(), getTemplate().getCloseTime() * 1000);
_autoCloseTask = ThreadPoolManager.schedule(new AutoClose(), getTemplate().getCloseTime() * 1000);
}
class AutoClose implements Runnable
@@ -681,7 +681,7 @@ public final class L2DoorInstance extends L2Character
{
delay += Rnd.get(getTemplate().getRandomTime());
}
ThreadPoolManager.getInstance().scheduleGeneral(this, delay * 1000);
ThreadPoolManager.schedule(this, delay * 1000);
}
}

View File

@@ -145,7 +145,7 @@ public class L2FortCommanderInstance extends L2DefenderInstance
{
broadcastSay(ChatType.NPC_SHOUT, npcString, npcString.getParamCount() == 1 ? attacker.getName() : null);
setCanTalk(false);
ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleTalkTask(), 10000);
ThreadPoolManager.schedule(new ScheduleTalkTask(), 10000);
}
}
}

View File

@@ -818,7 +818,7 @@ public final class L2PcInstance extends L2Playable
if (_PvPRegTask == null)
{
_PvPRegTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_PvPRegTask = ThreadPoolManager.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
@@ -2822,7 +2822,7 @@ public final class L2PcInstance extends L2Playable
getAI().setIntention(CtrlIntention.AI_INTENTION_REST);
broadcastPacket(new ChangeWaitType(this, ChangeWaitType.WT_SITTING));
// Schedule a sit down task to wait for the animation to finish
ThreadPoolManager.getInstance().scheduleGeneral(new SitDownTask(this), 2500);
ThreadPoolManager.schedule(new SitDownTask(this), 2500);
setBlockActions(true);
}
}
@@ -2845,7 +2845,7 @@ public final class L2PcInstance extends L2Playable
broadcastPacket(new ChangeWaitType(this, ChangeWaitType.WT_STANDING));
// Schedule a stand up task to wait for the animation to finish
ThreadPoolManager.getInstance().scheduleGeneral(new StandUpTask(this), 2500);
ThreadPoolManager.schedule(new StandUpTask(this), 2500);
}
}
@@ -4302,7 +4302,7 @@ public final class L2PcInstance extends L2Playable
}
if (Config.GAMEGUARD_ENFORCE)
{
ThreadPoolManager.getInstance().scheduleGeneral(new GameGuardCheckTask(this), 30 * 1000);
ThreadPoolManager.schedule(new GameGuardCheckTask(this), 30 * 1000);
}
}
@@ -8514,7 +8514,7 @@ public final class L2PcInstance extends L2Playable
_inventoryDisable = val;
if (val)
{
ThreadPoolManager.getInstance().scheduleGeneral(new InventoryEnableTask(this), 1500);
ThreadPoolManager.schedule(new InventoryEnableTask(this), 1500);
}
}
@@ -9816,7 +9816,7 @@ public final class L2PcInstance extends L2Playable
{
if (_taskWarnUserTakeBreak == null)
{
_taskWarnUserTakeBreak = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new WarnUserTakeBreakTask(this), 3600000, 3600000);
_taskWarnUserTakeBreak = ThreadPoolManager.scheduleAtFixedRate(new WarnUserTakeBreakTask(this), 3600000, 3600000);
}
}
@@ -9842,7 +9842,7 @@ public final class L2PcInstance extends L2Playable
{
if (_taskRentPet == null)
{
_taskRentPet = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new RentPetTask(this), seconds * 1000L, seconds * 1000L);
_taskRentPet = ThreadPoolManager.scheduleAtFixedRate(new RentPetTask(this), seconds * 1000L, seconds * 1000L);
}
}
@@ -9873,7 +9873,7 @@ public final class L2PcInstance extends L2Playable
final int timeinwater = (int) getStat().getValue(Stats.BREATH, 60000);
sendPacket(new SetupGauge(getObjectId(), 2, timeinwater));
_taskWater = ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(new WaterTask(this), timeinwater, 1000);
_taskWater = ThreadPoolManager.scheduleAtFixedRate(new WaterTask(this), timeinwater, 1000);
}
}
@@ -10254,7 +10254,7 @@ public final class L2PcInstance extends L2Playable
{
if (_teleportWatchdog == null)
{
_teleportWatchdog = ThreadPoolManager.getInstance().scheduleGeneral(new TeleportWatchdogTask(this), Config.TELEPORT_WATCHDOG_TIMEOUT * 1000);
_teleportWatchdog = ThreadPoolManager.schedule(new TeleportWatchdogTask(this), Config.TELEPORT_WATCHDOG_TIMEOUT * 1000);
}
}
}
@@ -11144,7 +11144,7 @@ public final class L2PcInstance extends L2Playable
}
if (_fameTask == null)
{
_fameTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new FameTask(this, fameFixRate), delay, delay);
_fameTask = ThreadPoolManager.scheduleAtFixedRate(new FameTask(this, fameFixRate), delay, delay);
}
}
@@ -11264,7 +11264,7 @@ public final class L2PcInstance extends L2Playable
_soulTask.cancel(false);
_soulTask = null;
}
_soulTask = ThreadPoolManager.getInstance().scheduleGeneral(new ResetSoulsTask(this), 600000);
_soulTask = ThreadPoolManager.schedule(new ResetSoulsTask(this), 600000);
}
@@ -11607,7 +11607,7 @@ public final class L2PcInstance extends L2Playable
sendPacket(new SetupGauge(3, (getCurrentFeed() * 10000) / getFeedConsume(), (getMaxFeed() * 10000) / getFeedConsume()));
if (!isDead())
{
_mountFeedTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new PetFeedTask(this), 10000, 10000);
_mountFeedTask = ThreadPoolManager.scheduleAtFixedRate(new PetFeedTask(this), 10000, 10000);
}
}
else if (_canFeed)
@@ -11617,7 +11617,7 @@ public final class L2PcInstance extends L2Playable
sendPacket(sg);
if (!isDead())
{
_mountFeedTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new PetFeedTask(this), 10000, 10000);
_mountFeedTask = ThreadPoolManager.scheduleAtFixedRate(new PetFeedTask(this), 10000, 10000);
}
}
}
@@ -11694,7 +11694,7 @@ public final class L2PcInstance extends L2Playable
public void enteredNoLanding(int delay)
{
_dismountTask = ThreadPoolManager.getInstance().scheduleGeneral(new DismountTask(this), delay * 1000);
_dismountTask = ThreadPoolManager.schedule(new DismountTask(this), delay * 1000);
}
public void exitedNoLanding()
@@ -11815,7 +11815,7 @@ public final class L2PcInstance extends L2Playable
_chargeTask.cancel(false);
_chargeTask = null;
}
_chargeTask = ThreadPoolManager.getInstance().scheduleGeneral(new ResetChargesTask(this), 600000);
_chargeTask = ThreadPoolManager.schedule(new ResetChargesTask(this), 600000);
}
/**
@@ -12880,7 +12880,7 @@ public final class L2PcInstance extends L2Playable
public void startRecoGiveTask()
{
// Create task to give new recommendations
_recoGiveTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new RecoGiveTask(this), 7200000, 3600000);
_recoGiveTask = ThreadPoolManager.scheduleAtFixedRate(new RecoGiveTask(this), 7200000, 3600000);
// Store new data
storeRecommendations();
@@ -13808,7 +13808,7 @@ public final class L2PcInstance extends L2Playable
stopOnlineTimeUpdateTask();
}
_onlineTimeUpdateTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(this::updateOnlineTime, 60 * 1000L, 60 * 1000L);
_onlineTimeUpdateTask = ThreadPoolManager.scheduleAtFixedRate(this::updateOnlineTime, 60 * 1000L, 60 * 1000L);
}
private void updateOnlineTime()

View File

@@ -1130,7 +1130,7 @@ public class L2PetInstance extends L2Summon
stopFeed();
if (!isDead() && (getOwner().getPet() == this))
{
_feedTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new FeedTask(), 10000, 10000);
_feedTask = ThreadPoolManager.scheduleAtFixedRate(new FeedTask(), 10000, 10000);
}
}

View File

@@ -106,27 +106,26 @@ public class L2RaceManagerInstance extends L2Npc
_managers = new CopyOnWriteArrayList<>();
final ThreadPoolManager s = ThreadPoolManager.getInstance();
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.TICKETS_ARE_NOW_AVAILABLE_FOR_MONSTER_RACE_S1), 0, 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.NOW_SELLING_TICKETS_FOR_MONSTER_RACE_S1), 30 * SECOND, 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.TICKETS_ARE_NOW_AVAILABLE_FOR_MONSTER_RACE_S1), MINUTE, 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.NOW_SELLING_TICKETS_FOR_MONSTER_RACE_S1), MINUTE + (30 * SECOND), 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_END_IN_S1_MINUTE_S), 2 * MINUTE, 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_END_IN_S1_MINUTE_S), 3 * MINUTE, 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_END_IN_S1_MINUTE_S), 4 * MINUTE, 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_END_IN_S1_MINUTE_S), 5 * MINUTE, 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_END_IN_S1_MINUTE_S), 6 * MINUTE, 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.TICKETS_SALES_ARE_CLOSED_FOR_MONSTER_RACE_S1_ODDS_ARE_POSTED), 7 * MINUTE, 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSTER_RACE_S2_WILL_BEGIN_IN_S1_MINUTE_S), 7 * MINUTE, 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSTER_RACE_S2_WILL_BEGIN_IN_S1_MINUTE_S), 8 * MINUTE, 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSTER_RACE_S1_WILL_BEGIN_IN_30_SECONDS), (8 * MINUTE) + (30 * SECOND), 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.MONSTER_RACE_S1_IS_ABOUT_TO_BEGIN_COUNTDOWN_IN_FIVE_SECONDS), (8 * MINUTE) + (50 * SECOND), 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.THE_RACE_WILL_BEGIN_IN_S1_SECOND_S), (8 * MINUTE) + (55 * SECOND), 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.THE_RACE_WILL_BEGIN_IN_S1_SECOND_S), (8 * MINUTE) + (56 * SECOND), 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.THE_RACE_WILL_BEGIN_IN_S1_SECOND_S), (8 * MINUTE) + (57 * SECOND), 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.THE_RACE_WILL_BEGIN_IN_S1_SECOND_S), (8 * MINUTE) + (58 * SECOND), 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.THE_RACE_WILL_BEGIN_IN_S1_SECOND_S), (8 * MINUTE) + (59 * SECOND), 10 * MINUTE);
s.scheduleGeneralAtFixedRate(new Announcement(SystemMessageId.THEY_RE_OFF), 9 * MINUTE, 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.TICKETS_ARE_NOW_AVAILABLE_FOR_MONSTER_RACE_S1), 0, 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.NOW_SELLING_TICKETS_FOR_MONSTER_RACE_S1), 30 * SECOND, 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.TICKETS_ARE_NOW_AVAILABLE_FOR_MONSTER_RACE_S1), MINUTE, 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.NOW_SELLING_TICKETS_FOR_MONSTER_RACE_S1), MINUTE + (30 * SECOND), 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_END_IN_S1_MINUTE_S), 2 * MINUTE, 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_END_IN_S1_MINUTE_S), 3 * MINUTE, 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_END_IN_S1_MINUTE_S), 4 * MINUTE, 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_END_IN_S1_MINUTE_S), 5 * MINUTE, 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_END_IN_S1_MINUTE_S), 6 * MINUTE, 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.TICKETS_SALES_ARE_CLOSED_FOR_MONSTER_RACE_S1_ODDS_ARE_POSTED), 7 * MINUTE, 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.MONSTER_RACE_S2_WILL_BEGIN_IN_S1_MINUTE_S), 7 * MINUTE, 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.MONSTER_RACE_S2_WILL_BEGIN_IN_S1_MINUTE_S), 8 * MINUTE, 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.MONSTER_RACE_S1_WILL_BEGIN_IN_30_SECONDS), (8 * MINUTE) + (30 * SECOND), 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.MONSTER_RACE_S1_IS_ABOUT_TO_BEGIN_COUNTDOWN_IN_FIVE_SECONDS), (8 * MINUTE) + (50 * SECOND), 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.THE_RACE_WILL_BEGIN_IN_S1_SECOND_S), (8 * MINUTE) + (55 * SECOND), 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.THE_RACE_WILL_BEGIN_IN_S1_SECOND_S), (8 * MINUTE) + (56 * SECOND), 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.THE_RACE_WILL_BEGIN_IN_S1_SECOND_S), (8 * MINUTE) + (57 * SECOND), 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.THE_RACE_WILL_BEGIN_IN_S1_SECOND_S), (8 * MINUTE) + (58 * SECOND), 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.THE_RACE_WILL_BEGIN_IN_S1_SECOND_S), (8 * MINUTE) + (59 * SECOND), 10 * MINUTE);
ThreadPoolManager.scheduleAtFixedRate(new Announcement(SystemMessageId.THEY_RE_OFF), 9 * MINUTE, 10 * MINUTE);
}
_managers.add(this);
}
@@ -244,7 +243,7 @@ public class L2RaceManagerInstance extends L2Npc
_packet = new MonRaceInfo(_codes[1][0], _codes[1][1], race.getMonsters(), race.getSpeeds());
sendMonsterInfo();
ThreadPoolManager.getInstance().scheduleGeneral(new RunRace(), 5000);
ThreadPoolManager.schedule(new RunRace(), 5000);
}
else
{
@@ -549,7 +548,7 @@ public class L2RaceManagerInstance extends L2Npc
{
_packet = new MonRaceInfo(_codes[2][0], _codes[2][1], MonsterRace.getInstance().getMonsters(), MonsterRace.getInstance().getSpeeds());
sendMonsterInfo();
ThreadPoolManager.getInstance().scheduleGeneral(new RunEnd(), 30000);
ThreadPoolManager.schedule(new RunEnd(), 30000);
}
}

View File

@@ -72,7 +72,7 @@ public class L2RaidBossInstance extends L2MonsterInstance
@Override
protected void startMaintenanceTask()
{
_maintenanceTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(() -> checkAndReturnToSpawn(), 60000, getMaintenanceInterval() + Rnd.get(5000));
_maintenanceTask = ThreadPoolManager.scheduleAtFixedRate(() -> checkAndReturnToSpawn(), 60000, getMaintenanceInterval() + Rnd.get(5000));
}
protected void checkAndReturnToSpawn()

View File

@@ -85,7 +85,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
super.onSpawn();
if ((_lifeTime > 0) && (_summonLifeTask == null))
{
_summonLifeTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(this, 0, 5000);
_summonLifeTask = ThreadPoolManager.scheduleAtFixedRate(this, 0, 5000);
}
}

View File

@@ -163,7 +163,7 @@ public class L2SiegeFlagInstance extends L2Npc
// send warning to owners of headquarters that theirs base is under attack
_clan.broadcastToOnlineMembers(SystemMessage.getSystemMessage(SystemMessageId.YOUR_BASE_IS_BEING_ATTACKED));
setCanTalk(false);
ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleTalkTask(), 20000);
ThreadPoolManager.schedule(new ScheduleTalkTask(), 20000);
}
}
}

View File

@@ -153,7 +153,7 @@ public final class L2TamedBeastInstance extends L2FeedableBeastInstance
{
_durationCheckTask.cancel(true);
}
_durationCheckTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new CheckDuration(this), DURATION_CHECK_INTERVAL, DURATION_CHECK_INTERVAL);
_durationCheckTask = ThreadPoolManager.scheduleAtFixedRate(new CheckDuration(this), DURATION_CHECK_INTERVAL, DURATION_CHECK_INTERVAL);
}
}
@@ -217,10 +217,10 @@ public final class L2TamedBeastInstance extends L2FeedableBeastInstance
int delay = 100;
for (Skill skill : _beastSkills)
{
ThreadPoolManager.getInstance().scheduleGeneral(new buffCast(skill), delay);
ThreadPoolManager.schedule(new buffCast(skill), delay);
delay += (100 + skill.getHitTime());
}
ThreadPoolManager.getInstance().scheduleGeneral(new buffCast(null), delay);
ThreadPoolManager.schedule(new buffCast(null), delay);
}
private class buffCast implements Runnable
@@ -284,7 +284,7 @@ public final class L2TamedBeastInstance extends L2FeedableBeastInstance
{
_buffTask.cancel(true);
}
_buffTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new CheckOwnerBuffs(this, totalBuffsAvailable), BUFF_INTERVAL, BUFF_INTERVAL);
_buffTask = ThreadPoolManager.scheduleAtFixedRate(new CheckOwnerBuffs(this, totalBuffsAvailable), BUFF_INTERVAL, BUFF_INTERVAL);
}
}
else

View File

@@ -77,7 +77,7 @@ public final class L2TrapInstance extends L2Npc
_remainingTime = _lifeTime;
if (_skill != null)
{
_trapTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new TrapTask(this), TICK, TICK);
_trapTask = ThreadPoolManager.scheduleAtFixedRate(new TrapTask(this), TICK, TICK);
}
}
@@ -341,7 +341,7 @@ public final class L2TrapInstance extends L2Npc
EventDispatcher.getInstance().notifyEventAsync(new OnTrapAction(this, target, TrapAction.TRAP_TRIGGERED), this);
ThreadPoolManager.getInstance().scheduleGeneral(new TrapTriggerTask(this), 500);
ThreadPoolManager.schedule(new TrapTriggerTask(this), 500);
}
public void unSummon()

View File

@@ -55,7 +55,7 @@ public abstract class AbstractRequest
public void scheduleTimeout(long delay)
{
_timeOutTask = ThreadPoolManager.getInstance().scheduleGeneral(this::onTimeout, delay);
_timeOutTask = ThreadPoolManager.schedule(this::onTimeout, delay);
}
public boolean isTimeout()

View File

@@ -216,7 +216,7 @@ public class CharStatus
final int period = Formulas.getRegeneratePeriod(getActiveChar());
// Create the HP/MP/CP Regeneration task
_regTask = ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(new RegenTask(), period, period);
_regTask = ThreadPoolManager.scheduleAtFixedRate(new RegenTask(), period, period);
}
}

View File

@@ -48,7 +48,7 @@ public final class CommandChannelTimer implements Runnable
}
else
{
ThreadPoolManager.getInstance().scheduleGeneral(this, 10000); // 10sec
ThreadPoolManager.schedule(this, 10000); // 10sec
}
}

View File

@@ -91,7 +91,7 @@ public class RandomAnimationTask implements Runnable
final int interval = Rnd.get(minWait, maxWait) * 1000;
// Create a RandomAnimation Task that will be launched after the calculated delay
ThreadPoolManager.getInstance().scheduleGeneral(this, interval);
ThreadPoolManager.schedule(this, interval);
}
/**

View File

@@ -38,7 +38,7 @@ public class TrapTriggerTask implements Runnable
try
{
_trap.doCast(_trap.getSkill());
ThreadPoolManager.getInstance().scheduleGeneral(new TrapUnsummonTask(_trap), _trap.getSkill().getHitTime() + 300);
ThreadPoolManager.schedule(new TrapUnsummonTask(_trap), _trap.getSkill().getHitTime() + 300);
}
catch (Exception e)
{

View File

@@ -51,7 +51,7 @@ public class FlyMoveStartTask implements Runnable
if (!_player.hasRequest(SayuneRequest.class))
{
_player.sendPacket(ExNotifyFlyMoveStart.STATIC_PACKET);
ThreadPoolManager.getInstance().scheduleGeneral(this, 1000L);
ThreadPoolManager.schedule(this, 1000L);
}
}
}

View File

@@ -160,7 +160,7 @@ public final class AutoAnnouncement extends Announcement implements Runnable
_task.cancel(false);
}
_currentState = _repeat;
_task = ThreadPoolManager.getInstance().scheduleGeneral(this, _initial);
_task = ThreadPoolManager.schedule(this, _initial);
}
@Override
@@ -178,7 +178,7 @@ public final class AutoAnnouncement extends Announcement implements Runnable
_currentState--;
}
_task = ThreadPoolManager.getInstance().scheduleGeneral(this, _delay);
_task = ThreadPoolManager.schedule(this, _delay);
}
}
}

View File

@@ -119,7 +119,7 @@ public final class Product
}
if ((_restockTask == null) || _restockTask.isDone())
{
_restockTask = ThreadPoolManager.getInstance().scheduleGeneral(this::restock, getRestockDelay());
_restockTask = ThreadPoolManager.schedule(this::restock, getRestockDelay());
}
final boolean result = _count.addAndGet(-val) >= 0;
save();
@@ -136,7 +136,7 @@ public final class Product
final long remainTime = nextRestockTime - System.currentTimeMillis();
if (remainTime > 0)
{
_restockTask = ThreadPoolManager.getInstance().scheduleGeneral(this::restock, remainTime);
_restockTask = ThreadPoolManager.schedule(this::restock, remainTime);
}
else
{

Some files were not shown because too many files have changed in this diff Show More