mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
Updates pull request from Roman Tsypuk to convert the build system from
ant to gradle. Removes linux and windows application launch scripts and produces an executable jar with all resources included.
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package io.github.dsheirer.controller;
|
||||
|
||||
import io.github.dsheirer.util.ThreadPool;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* Thread factory that applies custom names to threads
|
||||
*/
|
||||
public class NamingThreadFactory implements ThreadFactory
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(ThreadPool.class);
|
||||
|
||||
private static final AtomicInteger mPoolNumber = new AtomicInteger(1);
|
||||
|
||||
private final ThreadGroup mThreadGroup;
|
||||
|
||||
private final AtomicInteger mThreadNumber = new AtomicInteger(1);
|
||||
|
||||
private final String mNamePrefix;
|
||||
|
||||
public NamingThreadFactory( String prefix )
|
||||
{
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
|
||||
mThreadGroup = (s != null)? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
|
||||
|
||||
mNamePrefix = prefix + " pool-" + mPoolNumber.getAndIncrement() + "-thread-";
|
||||
}
|
||||
|
||||
public Thread newThread( Runnable runnable )
|
||||
{
|
||||
Thread thread = new Thread(mThreadGroup, runnable,
|
||||
mNamePrefix + mThreadNumber.getAndIncrement(), 0 );
|
||||
|
||||
if( thread.isDaemon() )
|
||||
{
|
||||
thread.setDaemon( false );
|
||||
}
|
||||
|
||||
if( thread.getPriority() != Thread.NORM_PRIORITY )
|
||||
{
|
||||
thread.setPriority( Thread.NORM_PRIORITY );
|
||||
}
|
||||
|
||||
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
|
||||
{
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e)
|
||||
{
|
||||
mLog.error("Error while executing runnable in scheduled thread pool [" + t.getName() + "]", e);
|
||||
}
|
||||
});
|
||||
|
||||
return thread;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user