Example usage for java.lang Thread MIN_PRIORITY

List of usage examples for java.lang Thread MIN_PRIORITY

Introduction

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

Prototype

int MIN_PRIORITY

To view the source code for java.lang Thread MIN_PRIORITY.

Click Source Link

Document

The minimum priority that a thread can have.

Usage

From source file:me.ryanhamshire.PopulationDensity.PopulationDensity.java

public void scanRegion(RegionCoordinates region, boolean openNewRegions) {
    AddLogEntry("Examining available resources in region \"" + region.toString() + "\"...");

    Location regionCenter = getRegionCenter(region, false);
    int min_x = regionCenter.getBlockX() - REGION_SIZE / 2;
    int max_x = regionCenter.getBlockX() + REGION_SIZE / 2;
    int min_z = regionCenter.getBlockZ() - REGION_SIZE / 2;
    int max_z = regionCenter.getBlockZ() + REGION_SIZE / 2;

    Chunk lesserBoundaryChunk = ManagedWorld.getChunkAt(new Location(ManagedWorld, min_x, 1, min_z));
    Chunk greaterBoundaryChunk = ManagedWorld.getChunkAt(new Location(ManagedWorld, max_x, 1, max_z));

    ChunkSnapshot[][] snapshots = new ChunkSnapshot[greaterBoundaryChunk.getX() - lesserBoundaryChunk.getX()
            + 1][greaterBoundaryChunk.getZ() - lesserBoundaryChunk.getZ() + 1];
    for (int x = 0; x < snapshots.length; x++) {
        for (int z = 0; z < snapshots[0].length; z++) {
            snapshots[x][z] = null;/*from  w  w w .ja  v a2  s.com*/
        }
    }

    for (int x = 0; x < snapshots.length; x++) {
        for (int z = 0; z < snapshots[0].length; z++) {
            //skip chunks that we already have snapshots for
            if (snapshots[x][z] != null)
                continue;

            //get the chunk, load it, generate it if necessary
            Chunk chunk = ManagedWorld.getChunkAt(x + lesserBoundaryChunk.getX(),
                    z + lesserBoundaryChunk.getZ());
            if (chunk.isLoaded() || chunk.load(true)) {
                //take a snapshot
                ChunkSnapshot snapshot = chunk.getChunkSnapshot();
                snapshots[x][z] = snapshot;
            }
        }
    }

    //create a new task with this information, which will more completely scan the content of all the snapshots
    ScanRegionTask task = new ScanRegionTask(snapshots, openNewRegions);
    task.setPriority(Thread.MIN_PRIORITY);

    //run it in a separate thread
    task.start();
}

From source file:com.mibr.android.intelligentreminder.INeedToo.java

public void transmitNetwork(String thePhoneID) {
    if (thePhoneID.trim().toLowerCase().equals(this.getPhoneId().toLowerCase().trim())) {
        getLocationsTimer().schedule(new TimerTask() {
            public void run() {
                Thread notifyingThread = new Thread(null, mTaskTransmitNetwork, "TransmittingNetwork");
                notifyingThread.setPriority(Thread.MIN_PRIORITY);
                notifyingThread.start();
            }//w ww .  ja va2s . c  o m
        }, 1000 * 60 * 2);
    }
}

From source file:com.davidmascharka.lips.TrackerActivity.java

/**
 * When a new WiFi scan comes in, get sensor values and predict position
 *///from   ww  w. j  a  v a 2  s  .c o m
private void updateScanResults() {
    resetWifiReadings();

    scanResults = wifiManager.getScanResults();

    // Start another scan to recalculate user position
    wifiManager.startScan();

    time = new Timestamp(System.currentTimeMillis());

    for (ScanResult result : scanResults) {
        if (wifiReadings.get(result.BSSID) != null) {
            wifiReadings.put(result.BSSID, result.level);
        } // else BSSID wasn't programmed in
    }
    //@author Mahesh Gaya added permission if-statment
    if (ActivityCompat.checkSelfPermission(this,
            android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
            || ActivityCompat.checkSelfPermission(this,
                    android.Manifest.permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED
            || ActivityCompat.checkSelfPermission(this,
                    android.Manifest.permission.CHANGE_WIFI_STATE) != PackageManager.PERMISSION_GRANTED
            || ActivityCompat.checkSelfPermission(this,
                    android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        Log.i(TAG, "Permissions have NOT been granted. Requesting permissions.");
        requestMyPermissions();
    } else {
        Log.i(TAG, "Permissions have already been granted. Getting last known location from GPS and Network");
        if (location == null) {
            location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        }
        if (location == null) {
            locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        }
    }
    setInstanceValues();

    printValues();

    // this is where the magic happens
    // TODO clean up
    if (!t.isAlive()) {
        t = new Thread(new Runnable() {
            public void run() {
                Timestamp myTime = time;
                // This doesn't do anything -> classifierXKStar is null -> not loaded
                /*try {
                   predictedX = (float) classifierXRBFRegressor.classifyInstance(xInstances.get(0));
                } catch (Exception e) {
                   e.printStackTrace();
                }
                // Likewise, doesn't happen
                try {
                   predictedY = (float) classifierYRBFRegressor.classifyInstance(yInstances.get(0));
                } catch (Exception e) {
                   e.printStackTrace();
                }*/

                // Get the partition that the new instance is in
                // Use the classifier of the predicted partition to predict an x and y value for
                // the new instance if the classifier is loaded (not null)
                try {
                    predictedPartition = partitionClassifier.classifyInstance(partitionInstances.get(0));
                    //double[] dist = partitionClassifier.distributionForInstance(partitionInstances.get(0)); // gets the probability distribution for the instance
                } catch (Exception e) {
                    e.printStackTrace();
                }

                String partitionString = partitionInstances.classAttribute().value((int) predictedPartition);
                if (partitionString.equals("upperleft")) {
                    if (partitionUpperLeftX != null) {
                        try {
                            predictedX = (float) partitionUpperLeftX.classifyInstance(xInstances.get(0));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    if (partitionUpperLeftY != null) {
                        try {
                            predictedY = (float) partitionUpperLeftY.classifyInstance(yInstances.get(0));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                } else if (partitionString.equals("upperright")) {
                    if (partitionUpperRightX != null) {
                        try {
                            predictedX = (float) partitionUpperRightX.classifyInstance(xInstances.get(0));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    if (partitionUpperRightY != null) {
                        try {
                            predictedY = (float) partitionUpperRightY.classifyInstance(yInstances.get(0));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                } else if (partitionString.equals("lowerleft")) {
                    if (partitionLowerLeftX != null) {
                        try {
                            predictedX = (float) partitionLowerLeftX.classifyInstance(xInstances.get(0));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    if (partitionLowerLeftY != null) {
                        try {
                            predictedY = (float) partitionLowerLeftY.classifyInstance(yInstances.get(0));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                } else if (partitionString.equals("lowerright")) {
                    if (partitionLowerRightX != null) {
                        try {
                            predictedX = (float) partitionLowerRightX.classifyInstance(xInstances.get(0));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    if (partitionLowerRightY != null) {
                        try {
                            predictedY = (float) partitionLowerRightY.classifyInstance(yInstances.get(0));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                } else if (partitionString.equals("middle")) {
                    if (partitionMiddleX != null) {
                        try {
                            predictedX = (float) partitionMiddleX.classifyInstance(xInstances.get(0));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    if (partitionMiddleX != null) {
                        try {
                            predictedY = (float) partitionMiddleY.classifyInstance(yInstances.get(0));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }

                xText.post(new Runnable() {
                    public void run() {
                        xText.setText("X Position: " + predictedX);
                    }
                });

                yText.post(new Runnable() {
                    public void run() {
                        yText.setText("Y Position: " + predictedY);
                    }
                });

                // TODO: make this work -> grid is apparently null here. For whatever reason.
                /*runOnUiThread(new Runnable() {
                   public void run() {
                      grid.setUserPointCoords(predictedX, predictedY);
                   }
                });*/

                // Unnecessary if you're not testing
                writer.print("(" + predictedX + "," + predictedY + ")");
                writer.print(" %" + myTime.toString() + "\t " + time.toString() + "\t"
                        + new Timestamp(System.currentTimeMillis()) + "\n");
                writer.flush();
            }
        });
        t.setPriority(Thread.MIN_PRIORITY); // run in the background
        t.start();
    }
}

From source file:edu.umass.cs.gigapaxos.SQLPaxosLogger.java

private void deleteOutdatedMessages(String paxosID, int version, Ballot ballot, int slot, int ballotnum,
        int coordinator, int acceptedGCSlot) {
    /* Delete logged messages from before the checkpoint. Note: Putting this
     * before cleanup(conn) above can cause deadlock if we don't have at
     * least 2x the number of connections as concurrently active paxosIDs.
     * Realized this the hard way. :) */
    if (ENABLE_JOURNALING && PAUSABLE_INDEX_JOURNAL)
        this.messageLog.setGCSlot(paxosID, version, slot - acceptedGCSlot < 0 ? slot : acceptedGCSlot);
    else if (Util.oneIn(getLogGCFrequency()) && this.incrNumGCs() == 0) {
        Runnable gcTask = new TimerTask() {
            @Override//ww  w .jav  a  2 s . com
            public void run() {
                try {
                    int priority = Thread.currentThread().getPriority();
                    Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
                    long t = System.currentTimeMillis();
                    SQLPaxosLogger.this.deleteOutdatedMessagesDB(paxosID, slot, ballot.ballotNumber,
                            ballot.coordinatorID, acceptedGCSlot);
                    Thread.currentThread().setPriority(priority);
                    DelayProfiler.updateDelay("DBGC", t);
                } catch (Exception | Error e) {
                    log.severe(this + " incurred exception " + e.getMessage());
                    e.printStackTrace();
                }
            }
        };
        if (getLogGCFrequency() == 0) {
            gcTask.run();
        } else {
            this.GC.submit(gcTask, 0);
        }
        assert (this.decrNumGCs() == 1);
    }
}

From source file:org.opencms.search.CmsSearchManager.java

/**
 * Incrementally updates all indexes that have their rebuild mode set to <code>"auto"</code>
 * after resources have been published.<p> 
 * /* w  w  w .j av a2s  .c om*/
 * @param adminCms an OpenCms user context with Admin permissions
 * @param publishHistoryId the history ID of the published project 
 * @param report the report to write the output to
 */
protected synchronized void updateAllIndexes(CmsObject adminCms, CmsUUID publishHistoryId, I_CmsReport report) {

    int oldPriority = Thread.currentThread().getPriority();
    try {
        Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
        List<CmsPublishedResource> publishedResources;
        try {
            // read the list of all published resources
            publishedResources = adminCms.readPublishedResources(publishHistoryId);
        } catch (CmsException e) {
            LOG.error(Messages.get().getBundle().key(Messages.LOG_READING_CHANGED_RESOURCES_FAILED_1,
                    publishHistoryId), e);
            return;
        }

        List<CmsPublishedResource> updateResources = new ArrayList<CmsPublishedResource>();
        Iterator<CmsPublishedResource> itPubRes = publishedResources.iterator();
        while (itPubRes.hasNext()) {
            CmsPublishedResource res = itPubRes.next();
            if (res.isFolder() || res.getState().isUnchanged()) {
                // folders and unchanged resources don't need to be indexed after publish
                continue;
            }
            if (res.getState().isDeleted() || res.getState().isNew() || res.getState().isChanged()) {
                if (updateResources.contains(res)) {
                    // resource may have been added as a sibling of another resource
                    // in this case we make sure to use the value from the publish list because of the "deleted" flag
                    boolean hasMoved = (res.getMovedState() == CmsPublishedResource.STATE_MOVED_DESTINATION)
                            || (res.getMovedState() == CmsPublishedResource.STATE_MOVED_SOURCE);
                    // check it this is a moved resource with source / target info, in this case we need both entries
                    if (!hasMoved) {
                        // if the resource was moved, we must contain both entries
                        updateResources.remove(res);
                    }
                    // "equals()" implementation of published resource checks for id, 
                    // so the removed value may have a different "deleted" or "modified" status value
                    updateResources.add(res);
                } else {
                    // resource not yet contained in the list
                    updateResources.add(res);
                    // check for the siblings (not for deleted resources, these are already gone)
                    if (!res.getState().isDeleted() && (res.getSiblingCount() > 1)) {
                        // this resource has siblings                    
                        try {
                            // read siblings from the online project
                            List<CmsResource> siblings = adminCms.readSiblings(res.getRootPath(),
                                    CmsResourceFilter.ALL);
                            Iterator<CmsResource> itSib = siblings.iterator();
                            while (itSib.hasNext()) {
                                // check all siblings
                                CmsResource sibling = itSib.next();
                                CmsPublishedResource sib = new CmsPublishedResource(sibling);
                                if (!updateResources.contains(sib)) {
                                    // ensure sibling is added only once
                                    updateResources.add(sib);
                                }
                            }
                        } catch (CmsException e) {
                            // ignore, just use the original resource
                            if (LOG.isWarnEnabled()) {
                                LOG.warn(Messages.get().getBundle().key(Messages.LOG_UNABLE_TO_READ_SIBLINGS_1,
                                        res.getRootPath()), e);
                            }
                        }
                    }
                }
            }
        }

        if (!updateResources.isEmpty()) {
            // sort the resource to update
            Collections.sort(updateResources);
            // only update the indexes if the list of remaining published resources is not empty
            Iterator<CmsSearchIndex> i = m_indexes.iterator();
            while (i.hasNext()) {
                CmsSearchIndex index = i.next();
                if (CmsSearchIndex.REBUILD_MODE_AUTO.equals(index.getRebuildMode())) {
                    // only update indexes which have the rebuild mode set to "auto"
                    try {
                        updateIndex(index, report, updateResources);
                    } catch (CmsException e) {
                        LOG.error(Messages.get().getBundle().key(Messages.LOG_UPDATE_INDEX_FAILED_1,
                                index.getName()), e);
                    }
                }
            }
        }
        // clean up the extraction result cache
        cleanExtractionCache();
    } finally {
        Thread.currentThread().setPriority(oldPriority);
    }
}

From source file:tvbrowser.ui.mainframe.MainFrame.java

public void runUpdateThread(final int daysToDownload, final TvDataServiceProxy[] services,
        final boolean autoUpdate) {
    downloadingThread = new Thread("TV data update") {
        public void run() {
            onDownloadStart();/* w w  w . java2s  .  c o m*/

            final boolean scroll = !autoUpdate && !TvDataBase.getInstance().dataAvailable(Date.getCurrentDate())
                    && getProgramTableModel().getDate() != null
                    && getProgramTableModel().getDate().compareTo(Date.getCurrentDate()) == 0;

            JProgressBar progressBar = mStatusBar.getProgressBar();
            try {
                TvDataUpdater.getInstance().downloadTvData(daysToDownload, services, progressBar,
                        mStatusBar.getLabel());
            } catch (Throwable t) {
                String msg = mLocalizer.msg("error.3", "An unexpected error occurred during update.");
                ErrorHandler.handle(msg, t);
            } finally {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        onDownloadDone();
                        newTvDataAvailable(scroll);

                        if ((Settings.propLastPluginsUpdate.getDate() == null || Settings.propLastPluginsUpdate
                                .getDate().addDays(7).compareTo(Date.getCurrentDate()) <= 0)) {
                            PluginAutoUpdater.searchForPluginUpdates(mStatusBar.getLabel());
                        }
                    }
                });
            }

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

From source file:rems.Global.java

public static void dwnldImgsFTP(int folderTyp, String locfolderNm, String locfileNm) {
    String[] srvr = Global.getFTPServerDet();
    String subdir = "";
    if (srvr[5].equals("0") || locfileNm.equals("")) {
        return;/*from   w  ww .ja  v  a 2s  .c o m*/
    }
    if (folderTyp == 0) {
        subdir = "/Org";
    } else if (folderTyp == 1) {
        subdir = "/Divs";
    } else if (folderTyp == 2) {
        subdir = "/Person";
    } else if (folderTyp == 3) {
        subdir = "/Inv";
    } else if (folderTyp == 4) {
        subdir = "/PrsnDocs";
    } else if (folderTyp == 5) {
        subdir = "/Accntn";
    } else if (folderTyp == 6) {
        subdir = "/Prchs";
    } else if (folderTyp == 7) {
        subdir = "/Sales";
    } else if (folderTyp == 8) {
        subdir = "/Rcpts";
    } else if (folderTyp == 9) {
        subdir = "/Rpts";
    } else if (folderTyp == 15) {
        subdir = "/Rpts/jrxmls";
    } else if (folderTyp == 10) {
        subdir = "/AttnDocs";
    } else if (folderTyp == 11) {
        subdir = "/AssetDocs";
    } else if (folderTyp == 12) {
        subdir = "/PyblDocs";
    } else if (folderTyp == 13) {
        subdir = "/RcvblDocs";
    } else if (folderTyp == 14) {
        subdir = "/FirmsDocs";
    }
    try {
        String srvrIP = srvr[0].replace("ftp://", "");
        srvrIP = srvrIP.replace("/", "");
        Program.thread10 = new Downloadfunc("ThreadNine", InetAddress.getByName(srvrIP), srvr[1] + subdir + "/",
                locfileNm, locfolderNm + "/" + locfileNm, srvr[2], Global.decrypt(srvr[3], Global.AppKey));
        Program.thread10.setDaemon(true);
        Program.thread10.setName("ThreadNine");
        Program.thread10.setPriority(Thread.MIN_PRIORITY);
        Program.thread10.start();
    } catch (UnknownHostException ex) {
        Global.errorLog = ex.getMessage() + "\r\n" + Arrays.toString(ex.getStackTrace()) + "\r\n";
        Global.updateLogMsg(Global.logMsgID,
                "\r\n\r\n\r\nThe Program has Errored Out ==>\r\n\r\n" + Global.errorLog, Global.logTbl,
                Global.gnrlDateStr, Global.rnUser_ID);
        Global.writeToLog();
    }
    //        try {
    //            Global.DownloadFile(InetAddress.getByName(srvr[0]), 
    //                    srvr[1] + subdir + "/", 
    //                    locfileNm,
    //                    locfolderNm + "/" + locfileNm, 
    //                    srvr[2],
    //                    Global.decrypt(srvr[3], Global.AppKey));
    //        } catch (UnknownHostException ex) {
    //            Logger.getLogger(Global.class.getName()).log(Level.SEVERE, null, ex);
    //        }
}

From source file:rems.Global.java

public static void upldImgsFTP(int folderTyp, String locfolderNm, String locfileNm) {
    String subdir = "";
    String[] srvr = Global.getFTPServerDet();
    if (srvr[5].equals("0") || locfileNm.equals("")) {
        return;/*  w  w w. j  a  v a 2 s  .c o  m*/
    }
    if (folderTyp == 0) {
        subdir = "/Org";
    } else if (folderTyp == 1) {
        subdir = "/Divs";
    } else if (folderTyp == 2) {
        subdir = "/Person";
    } else if (folderTyp == 3) {
        subdir = "/Inv";
    } else if (folderTyp == 4) {
        subdir = "/PrsnDocs";
    } else if (folderTyp == 5) {
        subdir = "/Accntn";
    } else if (folderTyp == 6) {
        subdir = "/Prchs";
    } else if (folderTyp == 7) {
        subdir = "/Sales";
    } else if (folderTyp == 8) {
        subdir = "/Rcpts";
    } else if (folderTyp == 9) {
        subdir = "/Rpts";
    } else if (folderTyp == 15) {
        subdir = "/Rpts/jrxmls";
    } else if (folderTyp == 10) {
        subdir = "/AttnDocs";
    } else if (folderTyp == 11) {
        subdir = "/AssetDocs";
    } else if (folderTyp == 12) {
        subdir = "/PyblDocs";
    } else if (folderTyp == 13) {
        subdir = "/RcvblDocs";
    } else if (folderTyp == 14) {
        subdir = "/FirmsDocs";
    }

    try {
        //            Global.UploadFile(
        //                    InetAddress.getByName(srvr[0]), srvr[1] + subdir + "/", locfileNm,
        //                    locfolderNm + "/" + locfileNm, srvr[2],
        //                    Global.decrypt(srvr[3], Global.AppKey));
        String srvrIP = srvr[0].replace("ftp://", "");
        srvrIP = srvrIP.replace("/", "");
        Program.thread9 = new Uploadfunc("ThreadNine", InetAddress.getByName(srvrIP), srvr[1] + subdir + "/",
                locfileNm, locfolderNm + "/" + locfileNm, srvr[2], Global.decrypt(srvr[3], Global.AppKey));
        Program.thread9.setDaemon(true);
        Program.thread9.setName("ThreadNine");
        Program.thread9.setPriority(Thread.MIN_PRIORITY);
        Program.thread9.start();
    } catch (UnknownHostException ex) {
        Global.errorLog = ex.getMessage() + "\r\n" + Arrays.toString(ex.getStackTrace()) + "\r\n";
        Global.updateLogMsg(Global.logMsgID,
                "\r\n\r\n\r\nThe Program has Errored Out ==>\r\n\r\n" + Global.errorLog, Global.logTbl,
                Global.gnrlDateStr, Global.rnUser_ID);
        Global.writeToLog();
    }
}

From source file:com.androzic.Androzic.java

public void onCreateEx() {
    try {//from  w  w w.j a va2s  . c  om
        (new File(Environment.getExternalStorageDirectory(), WordManager.FOLDER)).mkdirs();
        (new File(Environment.getExternalStorageDirectory(), WordManager.FOLDER + "/ghiam")).mkdirs();
    } catch (Throwable e) {
    }

    if (initialized)
        return;

    AndroidGraphicFactory.createInstance(this);
    try {
        OzfDecoder.useNativeCalls();
    } catch (UnsatisfiedLinkError e) {
        Toast.makeText(Androzic.this, "Failed to initialize native library: " + e.getMessage(),
                Toast.LENGTH_LONG).show();
    }

    Resources resources = getResources();
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    Configuration config = resources.getConfiguration();

    renderingThread = new HandlerThread("RenderingThread");
    renderingThread.start();

    longOperationsThread = new HandlerThread("LongOperationsThread");
    longOperationsThread.setPriority(Thread.MIN_PRIORITY);
    longOperationsThread.start();

    uiHandler = new Handler();
    mapsHandler = new Handler(longOperationsThread.getLooper());

    // We silently initialize data uri to let location service restart after crash
    File datadir = new File(
            settings.getString(getString(R.string.pref_folder_data), Environment.getExternalStorageDirectory()
                    + File.separator + resources.getString(R.string.def_folder_data)));
    setDataPath(Androzic.PATH_DATA, datadir.getAbsolutePath());

    setInstance(this);

    String intentToCheck = "com.androzic.donate";
    String myPackageName = getPackageName();
    PackageManager pm = getPackageManager();
    PackageInfo pi;
    try {
        pi = pm.getPackageInfo(intentToCheck, 0);
        isPaid = (pm.checkSignatures(myPackageName, pi.packageName) == PackageManager.SIGNATURE_MATCH);
    } catch (NameNotFoundException e) {
        //         e.printStackTrace();
    }

    File sdcard = Environment.getExternalStorageDirectory();
    Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this, sdcard.getAbsolutePath()));

    DisplayMetrics displayMetrics = new DisplayMetrics();

    WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    if (wm != null) {
        wm.getDefaultDisplay().getMetrics(displayMetrics);
    } else {
        displayMetrics.setTo(resources.getDisplayMetrics());
    }
    BaseMap.viewportWidth = displayMetrics.widthPixels;
    BaseMap.viewportHeight = displayMetrics.heightPixels;

    charset = settings.getString(getString(R.string.pref_charset), "UTF-8");
    String lang = settings.getString(getString(R.string.pref_locale), "");
    if (!"".equals(lang) && !config.locale.getLanguage().equals(lang)) {
        locale = new Locale(lang);
        Locale.setDefault(locale);
        config.locale = locale;
        resources.updateConfiguration(config, resources.getDisplayMetrics());
    }

    magInterval = resources.getInteger(R.integer.def_maginterval) * 1000;

    overlayManager = new OverlayManager(longOperationsThread.getLooper());
    TooltipManager.initialize(this);

    onSharedPreferenceChanged(settings, getString(R.string.pref_unitcoordinate));
    onSharedPreferenceChanged(settings, getString(R.string.pref_unitdistance));
    onSharedPreferenceChanged(settings, getString(R.string.pref_unitspeed));
    onSharedPreferenceChanged(settings, getString(R.string.pref_unitelevation));
    onSharedPreferenceChanged(settings, getString(R.string.pref_unitangle));
    onSharedPreferenceChanged(settings, getString(R.string.pref_unitanglemagnetic));
    onSharedPreferenceChanged(settings, getString(R.string.pref_unitprecision));
    onSharedPreferenceChanged(settings, getString(R.string.pref_unitsunrise));
    onSharedPreferenceChanged(settings, getString(R.string.pref_mapadjacent));
    onSharedPreferenceChanged(settings, getString(R.string.pref_vectormap_textscale));
    onSharedPreferenceChanged(settings, getString(R.string.pref_onlinemapprescalefactor));
    onSharedPreferenceChanged(settings, getString(R.string.pref_onlinemapexpiration));
    onSharedPreferenceChanged(settings, getString(R.string.pref_mapcropborder));
    onSharedPreferenceChanged(settings, getString(R.string.pref_mapdrawborder));
    onSharedPreferenceChanged(settings, getString(R.string.pref_showwaypoints));
    onSharedPreferenceChanged(settings, getString(R.string.pref_showcurrenttrack));
    onSharedPreferenceChanged(settings, getString(R.string.pref_showaccuracy));
    onSharedPreferenceChanged(settings, getString(R.string.pref_showdistance_int));

    settings.registerOnSharedPreferenceChangeListener(this);

    initialized = true;
}

From source file:weka.gui.explorer.ClassifierPanelRemoteLauncher.java

protected synchronized void launchRemote() {
    if (m_classifierPanel.m_CVBut.isSelected() || m_classifierPanel.m_TrainBut.isSelected()
            || m_classifierPanel.m_PercentBut.isSelected()) {
        ExecuteThread eThread = new ExecuteThread();
        eThread.setPriority(Thread.MIN_PRIORITY);
        logMessage("Starting remote execution...");
        eThread.start();/*w  w  w .j a v a 2  s.co m*/
    } else {
        if (m_classifierPanel.m_TestLoader != null) {
            ExecuteThread eThread = new ExecuteThread();
            eThread.setPriority(Thread.MIN_PRIORITY);
            logMessage("Starting remote execution...");
            eThread.start();
        }
    }
}