Example usage for java.lang Thread setPriority

List of usage examples for java.lang Thread setPriority

Introduction

In this page you can find the example usage for java.lang Thread setPriority.

Prototype

public final void setPriority(int newPriority) 

Source Link

Document

Changes the priority of this thread.

Usage

From source file:org.apache.axis2.clustering.DefaultLoadBalanceEventHandler.java

public void applicationMemberAdded(Member member) {
    Thread th = new Thread(new MemberAdder(member));
    th.setPriority(Thread.MAX_PRIORITY);
    th.start();/*from ww  w . j a v  a 2  s .c  o  m*/
}

From source file:com.sentaroh.android.TaskAutomation.TaskManager.java

static final private void startTaskOutsideThreadPool(final TaskManagerParms taskMgrParms,
        final EnvironmentParms envParms, final CommonUtilities util, final TaskExecutor tet) {
    if (envParms.statsUseOutsideThreadPoolCountTaskExec < Integer.MAX_VALUE)
        envParms.statsUseOutsideThreadPoolCountTaskExec++;
    else/*from w  w  w .j  a v  a2 s  .  c o  m*/
        envParms.statsUseOutsideThreadPoolCountTaskExec = 1;

    util.addLogMsg("I", "Task was started by outside the thread pool. " + tet.toSting());
    Thread th = new Thread() {
        @Override
        public void run() {
            tet.run();
        }
    };
    th.setPriority(Thread.NORM_PRIORITY - 3);
    th.start();
}

From source file:org.apache.axis2.clustering.tribes.AtMostOnceInterceptor.java

public AtMostOnceInterceptor() {
    Thread cleanupThread = new Thread(new MessageCleanupTask());
    cleanupThread.setPriority(Thread.MIN_PRIORITY);
    cleanupThread.setName("AtMostOnceInterceptor:Message-cleanup-thread"); // for debugging purposes
    cleanupThread.start();//www.  java  2s  .co  m
}

From source file:org.parosproxy.paros.core.scanner.Scanner.java

public void start(SiteNode startNode) {
    isStop = false;//from   w  w  w  .  ja  v a 2 s  .c o m
    log.info("scanner started");
    startTimeMillis = System.currentTimeMillis();
    this.startNode = startNode;
    Thread thread = new Thread(this);
    thread.setPriority(Thread.NORM_PRIORITY - 2);
    thread.start();
}

From source file:org.apache.axis2.clustering.control.wka.RpcMembershipRequestHandler.java

public Serializable replyRequest(Serializable msg, Member sender) {
    String domain = new String(sender.getDomain());

    if (log.isDebugEnabled()) {
        log.debug("Membership request received by RpcMembershipRequestHandler for domain " + domain);
        log.debug("local domain: " + new String(membershipManager.getDomain()));
    }//www.j  a va  2 s  . co m

    if (msg instanceof JoinGroupCommand) {
        log.info("Received JOIN message from " + TribesUtil.getName(sender));

        // process this join request - handing this job over to a new thread,
        // since the reply doesn't need to contain the member we're just going to
        // add.
        Thread th = new Thread(new ProcessJoinCommand(sender));
        th.setPriority(Thread.MAX_PRIORITY);
        th.start();

        // Return the list of current members to the caller
        MemberListCommand memListCmd = new MemberListCommand();
        memListCmd.setMembers(membershipManager.getMembers());
        if (log.isDebugEnabled()) {
            log.debug("Sent MEMBER_LIST to " + TribesUtil.getName(sender));
        }
        return memListCmd;
    } else if (msg instanceof MemberJoinedCommand) {
        log.info("Received MEMBER_JOINED message from " + TribesUtil.getName(sender));
        MemberJoinedCommand command = (MemberJoinedCommand) msg;
        if (log.isDebugEnabled()) {
            log.debug(command);
        }

        try {
            command.setMembershipManager(membershipManager);
            command.execute(null);
        } catch (ClusteringFault e) {
            String errMsg = "Cannot handle MEMBER_JOINED notification";
            log.error(errMsg, e);
            throw new RemoteProcessException(errMsg, e);
        }
    } else if (msg instanceof MemberListCommand) {
        try { //TODO: What if we receive more than one member list message?
            log.info("Received MEMBER_LIST message from " + TribesUtil.getName(sender));
            MemberListCommand command = (MemberListCommand) msg;
            command.setMembershipManager(membershipManager);
            command.execute(null);

            return "Processed MEMBER_LIST message";
            //TODO Send MEMBER_JOINED messages to all nodes
        } catch (ClusteringFault e) {
            String errMsg = "Cannot handle MEMBER_LIST message from " + TribesUtil.getName(sender);
            log.error(errMsg, e);
            throw new RemoteProcessException(errMsg, e);
        }
    }
    return null;
}

From source file:org.polymap.core.runtime.PolymapThreadPoolExecutor.java

public Thread newThread(Runnable r) {
    String prefix = "polymap-worker-";
    Thread t = new Thread(r, prefix + threadNumber.getAndIncrement());
    t.setDaemon(false);//from  ww w  .  jav  a  2s  .  c om
    t.setPriority(Thread.NORM_PRIORITY - 1);
    return t;
}

From source file:org.nebulaframework.grid.cluster.manager.services.heartbeat.HeartBeatTracker.java

/**
 * Starts the {@code HeartBeatTracker}./*www.  j  a  v  a  2s . c  o m*/
 */
public void start() {
    Thread beatThread = new Thread(this, "HeartBeatTracker-" + nodeId.toString());
    beatThread.setDaemon(true);
    beatThread.setPriority(Thread.MAX_PRIORITY);
    beatThread.start();
    log.debug("[HeartBeat] Started Tracking : " + nodeId);
}

From source file:com.dianping.resource.io.util.CustomizableThreadCreator.java

/**
 * Template method for the creation of a new {@link Thread}.
 * <p>The default implementation creates a new Thread for the given
 * {@link Runnable}, applying an appropriate thread name.
 * @param runnable the Runnable to execute
 * @see #nextThreadName()//  w w  w .j a  va  2  s.  co  m
 */
public Thread createThread(Runnable runnable) {
    Thread thread = new Thread(getThreadGroup(), runnable, nextThreadName());
    thread.setPriority(getThreadPriority());
    thread.setDaemon(isDaemon());
    return thread;
}

From source file:org.jajuk.util.UpgradeManager.java

/**
 * Require user to perform a deep scan.// www  . jav  a 2  s. c  om
 */
private static void deepScanRequest() {
    int reply = Messages.getChoice(Messages.getString("Warning.7"), JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.WARNING_MESSAGE);
    if (reply == JOptionPane.CANCEL_OPTION || reply == JOptionPane.NO_OPTION) {
        return;
    }
    if (reply == JOptionPane.YES_OPTION) {
        final Thread t = new Thread("Device Refresh Thread after upgrade") {
            @Override
            public void run() {
                List<Device> devices = DeviceManager.getInstance().getDevices();
                for (Device device : devices) {
                    if (device.isReady()) {
                        device.manualRefresh(false, false, true, null);
                    }
                }
            }
        };
        t.setPriority(Thread.MIN_PRIORITY);
        t.start();
    }
}

From source file:gda.gui.epics.EpicsMonitor.java

public void start() {
    if (!started) {
        Thread t = uk.ac.gda.util.ThreadManager.getThread(this);
        t.setPriority(java.lang.Thread.MIN_PRIORITY);
        t.start();/*from  ww w  . j  ava2s . com*/
        started = true;
    }
}