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:com.onecase.chatroom.service.DataLayerService.java

private void startSendThread() {
    Thread t = new Thread() {
        @Override//  w w w . j a  v  a 2  s  . c  o m
        public void run() {
            Looper.prepare();
            sendDataHandler = new OCHandler(Looper.myLooper());
            Looper.loop();
        }
    };
    t.setPriority(Thread.MIN_PRIORITY);
    t.start();
    while (sendDataHandler == null)
        ;
}

From source file:org.apparatus_templi.Coordinator.java

private static void startDrivers() {
    // this should never be called when drivers are currently running
    assert loadedDrivers.isEmpty() : "list of loaded drivers was not empty when starting drivers";
    assert driverThreads.isEmpty() : "list of driver threads was not empty when starting drivers";

    // Instantiate all drivers specified in the config file
    String driverList = prefs.getPreference(Prefs.Keys.driverList);
    assert driverList != null : "driver list should not be null";

    if (driverList == null || driverList.equals("")) {
        Log.w(TAG, "No drivers were specified in the configuration " + "file: '"
                + prefs.getPreference(Prefs.Keys.configFile) + "', nothing will be loaded");
    } else {/* w w w. ja v a2 s .  c o  m*/
        Log.c(TAG, "Initializing drivers...");
        String[] drivers = driverList.split(",");
        for (String driverClassName : drivers) {
            try {
                Class<?> c = Class.forName("org.apparatus_templi.driver." + driverClassName);
                Driver d = (Driver) c.newInstance();
                loadDriver(d);
            } catch (Exception e) {
                Log.d(TAG, "unable to load driver '" + driverClassName + "'");
            }
        }

    }

    // Start the driver threads
    for (String driverName : loadedDrivers.keySet()) {
        Log.c(TAG, "Starting driver " + driverName);
        Thread t = new Thread(loadedDrivers.get(driverName));
        t.setPriority(Thread.MIN_PRIORITY);
        driverThreads.put(loadedDrivers.get(driverName), t);
        t.start();
    }
}

From source file:org.jimcat.services.imagemanager.ImageManagerImpl.java

/**
 * simple constructor//  ww w  . j  av  a2  s .co m
 */
private ImageManagerImpl() {
    // create cache
    cache = Collections.synchronizedMap(new LinkedHashMap<ImageKey, ImageStore>());

    // create preloadservice
    preloadService = new PreloadService(this);

    // startup preloadservice
    Thread loader = new Thread(preloadService);
    loader.setDaemon(true);
    loader.setPriority(2);
    loader.start();
}

From source file:uk.ac.diamond.scisoft.JythonCreator.java

@Override
public void earlyStartup() {

    // initialiseInterpreter only when 
    // loader factory and function factory plugins 
    // are known.
    final Runnable runner = new Runnable() {
        @Override/*from   w w  w . j a  v  a  2  s .co m*/
        public void run() {

            try {
                Thread.sleep(500); // 1/2 second
            } catch (InterruptedException e) {
                logger.error("Cannot wait on worker thread", e);
            }

            while (!LoaderFactoryStartup.isStarted() || !FunctionFactoryStartup.isStarted()) {

                try {
                    Thread.sleep(500); // 1/2 second
                } catch (InterruptedException e) {
                    logger.error("Cannot sleep on worker thread", e);
                }
            }
            try {
                initialiseConsole();
                initialiseInterpreter(new NullProgressMonitor());
            } catch (Exception e) {
                logger.error("Cannot initialize the Jython interpreter.", e);
            }
        }
    };

    final Thread daemon = new Thread(runner);
    daemon.setPriority(Thread.MIN_PRIORITY);
    daemon.setDaemon(true);
    daemon.start();
}

From source file:net.sourceforge.subsonic.service.MediaScannerService.java

/**
 * Scans the media library.//  ww w. j a v a 2 s .c om
 * The scanning is done asynchronously, i.e., this method returns immediately.
 */
public synchronized void scanLibrary() {
    if (isScanning()) {
        return;
    }
    scanning = true;

    Thread thread = new Thread("MediaLibraryScanner") {
        @Override
        public void run() {
            doScanLibrary();
        }
    };

    thread.setPriority(Thread.MIN_PRIORITY);
    thread.start();
}

From source file:org.tsho.dmc2.managers.TrajectoryManager.java

private void launchThread(final boolean plotOnly) {

    plot.getPlotRenderer().setState(DmcPlotRenderer.STATE_NONE);

    Thread refreshJob = new RefreshThread();
    refreshJob.start();/*from  www . ja  v a 2s  . c  o  m*/

    Thread plotJob = new PlotThread("DMCDUE - Trajectory plotter", plotOnly);
    plotJob.setPriority(Thread.currentThread().getPriority() - 1);
    plotJob.start();
}

From source file:gda.gui.text.parameter.EpicsPanelParameterListener.java

@Override
public void vetoableChange(final PropertyChangeEvent e) throws PropertyVetoException {
    if (putTimeOut != null) {
        java.awt.Component c = null;
        Object obj = e.getSource();
        if (obj instanceof ParametersPanelBuilder.ParameterChangeEventSource) {
            Object field = ((ParametersPanelBuilder.ParameterChangeEventSource) obj).parameterField.field;
            if (field instanceof java.awt.Component) {
                c = (java.awt.Component) field;
            }//from   ww  w.  java2 s  . com
        }
        if (c != null)
            c.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
        vetoableChangeinNewThread(e);
        if (c != null)
            c.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
    } else {
        Thread t = uk.ac.gda.util.ThreadManager.getThread(new Runnable() {
            @Override
            public void run() {
                try {
                    vetoableChangeinNewThread(e);
                } catch (Exception ex) {
                    exceptionUtils.logException(logger, "vetoableChange", ex);
                }
            }
        });
        t.setPriority(java.lang.Thread.MIN_PRIORITY);
        t.start();
    }
}

From source file:com.brsanthu.googleanalytics.GoogleAnalytics.java

public Thread newThread(Runnable r) {
    Thread thread = new Thread(Thread.currentThread().getThreadGroup(), r,
            MessageFormat.format(threadNameFormat, threadNumber.getAndIncrement()), 0);
    thread.setDaemon(true);//from  w  w  w  .  j a v a2 s. c  om
    thread.setPriority(Thread.MIN_PRIORITY);
    return thread;
}

From source file:de.juwimm.cms.gui.admin.PanUnitGroupPerUser.java

public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand().equals(Constants.ACTION_CHANGE_USERACCOUNTS)) {
        Thread t = new Thread(new Runnable() {
            public void run() {
                reload();/*from w  w  w  . j a v a 2  s  .c  o  m*/
            }
        });
        t.setPriority(Thread.NORM_PRIORITY);
        t.start();
    }
}

From source file:com.apress.progwt.server.service.impl.SchoolServiceImpl.java

private void incrementSchoolPopularity(final School school) {
    Thread addTagThread = new Thread() {
        public void run() {
            try {
                schoolDAO.incrementSchoolPopularity(school);
            } catch (Exception e) {
                log.error("IncrementSchoolPopularity " + e);
            }/*w  w  w .  j  ava2s  . c o  m*/

            log.info("Increment Complete");
        }
    };
    addTagThread.setPriority(Thread.MIN_PRIORITY);
    addTagThread.start();
}