Updated ThreadProvider class.
This commit is contained in:
parent
a542426d7a
commit
b994d54621
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.threads;
|
package org.l2jmobius.gameserver.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,73 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.commons.threads;
|
package org.l2jmobius.commons.threads;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* ThreadFactory implementation that allows setting a thread name prefix, priority, and daemon status when creating new threads.
|
||||||
|
* @author Pantelis Andrianakis
|
||||||
|
* @since October 18th 2022
|
||||||
*/
|
*/
|
||||||
public class ThreadProvider implements ThreadFactory
|
public class ThreadProvider implements ThreadFactory
|
||||||
{
|
{
|
||||||
private final AtomicInteger _id = new AtomicInteger();
|
private final AtomicInteger _id = new AtomicInteger();
|
||||||
private final String _prefix;
|
private final String _prefix;
|
||||||
|
private final int _priority;
|
||||||
|
private final boolean _daemon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, normal thread priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
*/
|
||||||
public ThreadProvider(String prefix)
|
public ThreadProvider(String prefix)
|
||||||
{
|
{
|
||||||
_prefix = prefix + " ";
|
this(prefix, Thread.NORM_PRIORITY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and daemon status, and normal thread priority.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, boolean daemon)
|
||||||
|
{
|
||||||
|
this(prefix, Thread.NORM_PRIORITY, daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix and priority, and non-daemon threads.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority)
|
||||||
|
{
|
||||||
|
this(prefix, priority, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ThreadProvider with the specified prefix, priority, and daemon status.
|
||||||
|
* @param prefix the prefix to be used for thread names
|
||||||
|
* @param priority the priority of the threads
|
||||||
|
* @param daemon whether the threads should be daemon threads
|
||||||
|
*/
|
||||||
|
public ThreadProvider(String prefix, int priority, boolean daemon)
|
||||||
|
{
|
||||||
|
_prefix = prefix + " ";
|
||||||
|
_priority = priority;
|
||||||
|
_daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Thread with the specified Runnable object and with the properties defined in this ThreadProvider.
|
||||||
|
* @param runnable the object whose run method is invoked when this thread is started
|
||||||
|
* @return the created Thread
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable runnable)
|
public Thread newThread(Runnable runnable)
|
||||||
{
|
{
|
||||||
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
final Thread thread = new Thread(runnable, _prefix + _id.incrementAndGet());
|
||||||
thread.setPriority(Thread.NORM_PRIORITY);
|
thread.setPriority(_priority);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(_daemon);
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user