List of usage examples for java.lang Thread MIN_PRIORITY
int MIN_PRIORITY
To view the source code for java.lang Thread MIN_PRIORITY.
Click Source Link
From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java
private void startFileioTask(FileListAdapter fla, final int op_cd, final ArrayList<FileIoLinkParm> alp, String item_name, final NotifyEvent p_ntfy, final String lmp) { setAllFilelistItemUnChecked(fla);/*from w ww . jav a 2 s.c o m*/ @SuppressWarnings("unused") String dst = ""; String dt = null; @SuppressWarnings("unused") String nitem = item_name; mGp.fileIoWifiLockRequired = false; switch (op_cd) { case FILEIO_PARM_REMOTE_CREATE: mGp.fileIoWifiLockRequired = true; case FILEIO_PARM_LOCAL_CREATE: dt = "Create"; dst = item_name + " was created."; nitem = ""; break; case FILEIO_PARM_REMOTE_RENAME: mGp.fileIoWifiLockRequired = true; case FILEIO_PARM_LOCAL_RENAME: dt = "Rename"; dst = item_name + " was renamed."; nitem = ""; break; case FILEIO_PARM_REMOTE_DELETE: mGp.fileIoWifiLockRequired = true; case FILEIO_PARM_LOCAL_DELETE: dt = "Delete"; dst = "Following dirs/files were deleted."; break; case FILEIO_PARM_COPY_REMOTE_TO_LOCAL: case FILEIO_PARM_COPY_REMOTE_TO_REMOTE: case FILEIO_PARM_COPY_LOCAL_TO_REMOTE: mGp.fileIoWifiLockRequired = true; case FILEIO_PARM_COPY_LOCAL_TO_LOCAL: dt = "Copy"; dst = "Following dirs/files were copied."; break; case FILEIO_PARM_MOVE_REMOTE_TO_REMOTE: case FILEIO_PARM_MOVE_LOCAL_TO_REMOTE: case FILEIO_PARM_MOVE_REMOTE_TO_LOCAL: mGp.fileIoWifiLockRequired = true; case FILEIO_PARM_MOVE_LOCAL_TO_LOCAL: dt = "Move"; dst = "Following dirs/files were moved."; break; case FILEIO_PARM_DOWLOAD_REMOTE_FILE: mGp.fileIoWifiLockRequired = true; dt = "Download"; dst = ""; default: break; } mTcFileIoTask = new ThreadCtrl(); mTcFileIoTask.setEnabled(); if (currentTabName.equals(SMBEXPLORER_TAB_LOCAL)) { mGp.progressMsgView = mLocalProgressMsg; mGp.progressCancelBtn = mLocalProgressCancel; showLocalProgressView(); } else if (currentTabName.equals(SMBEXPLORER_TAB_REMOTE)) { mGp.progressMsgView = mRemoteProgressMsg; mGp.progressCancelBtn = mRemoteProgressCancel; showRemoteProgressView(); } mGp.progressMsgView.setText(dt); mGp.progressCancelBtn.setEnabled(true); mGp.progressCancelBtn.setText("Cancel"); mProgressOnClickListener = new OnClickListener() { @Override public void onClick(View v) { mTcFileIoTask.setDisabled(); mGp.progressCancelBtn.setEnabled(false); mGp.progressCancelBtn.setText("Cancelling"); } }; mGp.progressCancelBtn.setOnClickListener(mProgressOnClickListener); NotifyEvent ne = new NotifyEvent(mContext); ne.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { hideRemoteProgressView(); hideLocalProgressView(); if (!mTcFileIoTask.isThreadResultSuccess()) { if (p_ntfy != null) p_ntfy.notifyToListener(false, null); if (mTcFileIoTask.isThreadResultCancelled()) { // commonDlg.showCommonDialog(false,"W","File I/O task was cancelled.","",null); showDialogMsg("W", "File I/O task was cancelled.", ""); sendLogMsg("W", "File I/O task was cancelled."); // refreshFilelistView(); } else { // commonDlg.showCommonDialog(false,"E","File I/O task was failed."+"\n"+ // mTcFileIoTask.getThreadMessage(),"",null); showDialogMsg("E", "File I/O task was failed." + "\n" + mTcFileIoTask.getThreadMessage(), ""); sendLogMsg("E", "File I/O task was failed."); // refreshFilelistView(); } } else { if (p_ntfy != null) p_ntfy.notifyToListener(true, null); else refreshFilelistView(); } alp.clear(); if (isTaskDataExisted()) saveTaskData(); } @Override public void negativeResponse(Context c, Object[] o) { hideRemoteProgressView(); hideLocalProgressView(); } }); Thread th = new Thread(new FileIo(mGp, op_cd, alp, mTcFileIoTask, ne, this, lmp)); mTcFileIoTask.initThreadCtrl(); th.setPriority(Thread.MIN_PRIORITY); th.start(); }
From source file:carnero.cgeo.original.libs.Base.java
public void storeCache(App app, Activity activity, Cache cache, String geocode, int listId, Handler handler) { try {/*from w ww .ja v a2 s .c o m*/ // cache details if (cache != null) { final HashMap<String, String> params = new HashMap<String, String>(); params.put("geocode", cache.geocode); final Long searchId = searchByGeocode(params, listId, false); cache = app.getCache(searchId); } else if (geocode != null) { final HashMap<String, String> params = new HashMap<String, String>(); params.put("geocode", geocode); final Long searchId = searchByGeocode(params, listId, false); cache = app.getCache(searchId); } if (cache == null) { if (handler != null) { handler.sendMessage(new Message()); } return; } final HtmlImg imgGetter = new HtmlImg(activity, settings, cache.geocode, false, listId, true); // store images from description if (cache.description != null) { Html.fromHtml(cache.description, imgGetter, null); } // store spoilers if (cache.spoilers != null && cache.spoilers.isEmpty() == false) { for (Spoiler oneSpoiler : cache.spoilers) { imgGetter.getDrawable(oneSpoiler.url); } } // store map previews if (settings.storeOfflineMaps == 1 && cache.latitude != null && cache.longitude != null) { final String latlonMap = String.format((Locale) null, "%.6f", cache.latitude) + "," + String.format((Locale) null, "%.6f", cache.longitude); final Display display = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); final int maxWidth = display.getWidth() - 25; final int maxHeight = display.getHeight() - 25; int edge = 0; if (maxWidth > maxHeight) { edge = maxWidth; } else { edge = maxHeight; } String type = "mystery"; if (cache.found == true) { type = cache.type + "_found"; } else if (cache.disabled == true) { type = cache.type + "_disabled"; } else { type = cache.type; } final String markerUrl = urlencode_rfc3986( "http://cgeo.carnero.cc/_markers/marker_cache_" + type + ".png"); final StringBuilder waypoints = new StringBuilder(); if (cache.waypoints != null && cache.waypoints.size() > 0) { for (Waypoint waypoint : cache.waypoints) { if (waypoint.latitude == null && waypoint.longitude == null) { continue; } waypoints.append("&markers=icon%3Ahttp://cgeo.carnero.cc/_markers/marker_waypoint_"); waypoints.append(waypoint.type); waypoints.append(".png%7C"); waypoints.append(String.format((Locale) null, "%.6f", waypoint.latitude)); waypoints.append(","); waypoints.append(String.format((Locale) null, "%.6f", waypoint.longitude)); } } // download map images in separate background thread for higher performance final String code = cache.geocode; final int finalEdge = edge; Thread staticMapsThread = new Thread("getting static map") { @Override public void run() { MapImg mapGetter = new MapImg(settings, code); mapGetter.getDrawable( "http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=20&size=" + finalEdge + "x" + finalEdge + "&maptype=satellite&markers=icon%3A" + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false", 1); mapGetter.getDrawable( "http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=18&size=" + finalEdge + "x" + finalEdge + "&maptype=satellite&markers=icon%3A" + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false", 2); mapGetter.getDrawable( "http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=16&size=" + finalEdge + "x" + finalEdge + "&maptype=roadmap&markers=icon%3A" + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false", 3); mapGetter.getDrawable( "http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=14&size=" + finalEdge + "x" + finalEdge + "&maptype=roadmap&markers=icon%3A" + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false", 4); mapGetter.getDrawable( "http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=11&size=" + finalEdge + "x" + finalEdge + "&maptype=roadmap&markers=icon%3A" + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false", 5); } }; staticMapsThread.setPriority(Thread.MIN_PRIORITY); staticMapsThread.start(); } app.markStored(cache.geocode, listId); app.removeCacheFromCache(cache.geocode); if (handler != null) { handler.sendMessage(new Message()); } } catch (Exception e) { Log.e(Settings.tag, "cgBase.storeCache: " + e.toString()); } }
From source file:de.innovationgate.wgpublisher.WGACore.java
private void initQuartz() { try {/* w ww.j a v a 2s. co m*/ int threadCount = 5; String threadCountConfig = System.getProperty(SYSPROPERTY_QUARTZ_THREADCOUNT); if (threadCountConfig != null) { try { threadCount = Integer.parseInt(threadCountConfig); } catch (NumberFormatException e) { getLog().error("Unable to parse " + SYSPROPERTY_QUARTZ_THREADCOUNT + " as integer. Using default of " + threadCount); } } int threadPriority = Thread.MIN_PRIORITY; String threadPrioConfig = System.getProperty(SYSPROPERTY_QUARTZ_THREADPRIORITY); if (threadPrioConfig != null) { try { threadPriority = Integer.parseInt(threadPrioConfig); } catch (NumberFormatException e) { getLog().error("Unable to parse " + SYSPROPERTY_QUARTZ_THREADPRIORITY + " as integer. Using default of " + threadPriority); } } ThreadPool threadPool = new SimpleThreadPool(threadCount, threadPriority); threadPool.initialize(); JobStore jobStore = new RAMJobStore(); DirectSchedulerFactory.getInstance().createScheduler(threadPool, jobStore); _quartzScheduler = DirectSchedulerFactory.getInstance().getScheduler(); _quartzScheduler.start(); } catch (SchedulerException e) { getLog().fatal("Unable to start wga scheduler. Some background tasks may not run!", e); } }
From source file:carnero.cgeo.cgBase.java
public void storeCache(cgeoapplication app, Activity activity, cgCache cache, String geocode, int listId, Handler handler) {/*from w ww.j av a2 s.c om*/ try { // cache details if (cache != null) { final HashMap<String, String> params = new HashMap<String, String>(); params.put("geocode", cache.geocode); final Long searchId = searchByGeocode(params, listId, false); cache = app.getCache(searchId); } else if (geocode != null) { final HashMap<String, String> params = new HashMap<String, String>(); params.put("geocode", geocode); final Long searchId = searchByGeocode(params, listId, false); cache = app.getCache(searchId); } if (cache == null) { if (handler != null) { handler.sendMessage(new Message()); } return; } final cgHtmlImg imgGetter = new cgHtmlImg(activity, settings, cache.geocode, false, listId, true); // store images from description if (cache.description != null) { Html.fromHtml(cache.description, imgGetter, null); } // store spoilers if (cache.spoilers != null && cache.spoilers.isEmpty() == false) { for (cgSpoiler oneSpoiler : cache.spoilers) { imgGetter.getDrawable(oneSpoiler.url); } } // store map previews if (settings.storeOfflineMaps == 1 && cache.latitude != null && cache.longitude != null) { final String latlonMap = String.format((Locale) null, "%.6f", cache.latitude) + "," + String.format((Locale) null, "%.6f", cache.longitude); final Display display = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); final int maxWidth = display.getWidth() - 25; final int maxHeight = display.getHeight() - 25; int edge = 0; if (maxWidth > maxHeight) { edge = maxWidth; } else { edge = maxHeight; } String type = "mystery"; if (cache.found == true) { type = cache.type + "_found"; } else if (cache.disabled == true) { type = cache.type + "_disabled"; } else { type = cache.type; } final String markerUrl = urlencode_rfc3986( "http://cgeo.carnero.cc/_markers/marker_cache_" + type + ".png"); final StringBuilder waypoints = new StringBuilder(); if (cache.waypoints != null && cache.waypoints.size() > 0) { for (cgWaypoint waypoint : cache.waypoints) { if (waypoint.latitude == null && waypoint.longitude == null) { continue; } waypoints.append("&markers=icon%3Ahttp://cgeo.carnero.cc/_markers/marker_waypoint_"); waypoints.append(waypoint.type); waypoints.append(".png%7C"); waypoints.append(String.format((Locale) null, "%.6f", waypoint.latitude)); waypoints.append(","); waypoints.append(String.format((Locale) null, "%.6f", waypoint.longitude)); } } // download map images in separate background thread for higher performance final String code = cache.geocode; final int finalEdge = edge; Thread staticMapsThread = new Thread("getting static map") { @Override public void run() { cgMapImg mapGetter = new cgMapImg(settings, code); mapGetter.getDrawable( "http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=20&size=" + finalEdge + "x" + finalEdge + "&maptype=satellite&markers=icon%3A" + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false", 1); mapGetter.getDrawable( "http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=18&size=" + finalEdge + "x" + finalEdge + "&maptype=satellite&markers=icon%3A" + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false", 2); mapGetter.getDrawable( "http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=16&size=" + finalEdge + "x" + finalEdge + "&maptype=roadmap&markers=icon%3A" + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false", 3); mapGetter.getDrawable( "http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=14&size=" + finalEdge + "x" + finalEdge + "&maptype=roadmap&markers=icon%3A" + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false", 4); mapGetter.getDrawable( "http://maps.google.com/maps/api/staticmap?center=" + latlonMap + "&zoom=11&size=" + finalEdge + "x" + finalEdge + "&maptype=roadmap&markers=icon%3A" + markerUrl + "%7C" + latlonMap + waypoints.toString() + "&sensor=false", 5); } }; staticMapsThread.setPriority(Thread.MIN_PRIORITY); staticMapsThread.start(); } app.markStored(cache.geocode, listId); app.removeCacheFromCache(cache.geocode); if (handler != null) { handler.sendMessage(new Message()); } } catch (Exception e) { Log.e(cgSettings.tag, "cgBase.storeCache: " + e.toString()); } }
From source file:org.infoglue.deliver.util.CacheController.java
public static void evictWaitingCache() throws Exception { Timer t = new Timer(); String operatingMode = CmsPropertyHandler.getOperatingMode(); synchronized (RequestAnalyser.getRequestAnalyser()) { if (RequestAnalyser.getRequestAnalyser().getBlockRequests() && RequestAnalyser.getRequestAnalyser().getBlockRequestTime() < 30000) { logger.info("evictWaitingCache allready in progress - returning to avoid conflict"); return; } else if (RequestAnalyser.getRequestAnalyser().getBlockRequests() && RequestAnalyser.getRequestAnalyser().getBlockRequestTime() > 30000) logger.warn(//from www.j av a 2 s. com "An block must have gone wrong... there has gone over 30 seconds and still not reported done.. let's run anyway."); RequestAnalyser.getRequestAnalyser().setBlockRequests(true); } logger.info("evictWaitingCache starting"); logger.info("blocking"); synchronized (notifications) { if (notifications == null || notifications.size() == 0) { logger.info("No notifications..."); RequestAnalyser.getRequestAnalyser().setBlockRequests(false); return; } } logger.info("Had some notifications to handle:" + notifications.size()); WorkingPublicationThread wpt = new WorkingPublicationThread(); SelectiveLivePublicationThread pt = null; String livePublicationThreadClass = ""; try { livePublicationThreadClass = CmsPropertyHandler.getLivePublicationThreadClass(); if (operatingMode != null && operatingMode.equalsIgnoreCase("3")) //If published-mode we update entire cache to be sure.. { if (livePublicationThreadClass .equalsIgnoreCase("org.infoglue.deliver.util.SelectiveLivePublicationThread")) pt = new SelectiveLivePublicationThread(notifications); } } catch (Exception e) { logger.error("Could not get livePublicationThreadClass:" + e.getMessage(), e); } List localNotifications = new ArrayList(); boolean startedThread = false; if (pt == null) { logger.info("before notifications:" + notifications.size()); synchronized (notifications) { localNotifications.addAll(notifications); notifications.clear(); } Iterator i = localNotifications.iterator(); while (i.hasNext()) { CacheEvictionBean cacheEvictionBean = (CacheEvictionBean) i.next(); String className = cacheEvictionBean.getClassName(); logger.info("className:" + className); logger.info("pt:" + pt); //RequestAnalyser.getRequestAnalyser().addPublication("" + formatter.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss") + " - " + cacheEvictionBean.getClassName() + " - " + cacheEvictionBean.getObjectId()); if (pt == null) wpt.getCacheEvictionBeans().add(cacheEvictionBean); //else // pt.getCacheEvictionBeans().add(cacheEvictionBean); try { //Here we do what we need to if the server properties has changed. if (className != null && className.equalsIgnoreCase("ServerNodeProperties")) { try { logger.info("clearing InfoGlueAuthenticationFilter"); clearServerNodeProperty(true); logger.info("cleared InfoGlueAuthenticationFilter"); InfoGlueAuthenticationFilter.initializeProperties(); logger.info("initialized InfoGlueAuthenticationFilter"); logger.info("Shortening page stats"); RequestAnalyser.shortenPageStatistics(); } catch (Exception e1) { logger.warn("Could not refresh authentication filter:" + e1.getMessage(), e1); } catch (Throwable throwable) { logger.warn("Could not refresh authentication filter:" + throwable.getMessage(), throwable); } } if (operatingMode != null && !operatingMode.equalsIgnoreCase("3") && className != null && className.equalsIgnoreCase("PortletRegistry")) { logger.info("clearing portletRegistry"); clearPortlets(); logger.info("cleared portletRegistry"); } if (operatingMode != null && operatingMode.equalsIgnoreCase("3")) //If published-mode we update entire cache to be sure.. { if (!livePublicationThreadClass .equalsIgnoreCase("org.infoglue.deliver.util.SelectiveLivePublicationThread")) { logger.info("Starting publication thread..."); PublicationThread lpt = new PublicationThread(); lpt.setPriority(Thread.MIN_PRIORITY); lpt.start(); startedThread = true; logger.info("Done starting publication thread..."); } } } catch (Exception e) { logger.error("Cache eviction reported an error:" + e.getMessage(), e); } logger.info("Cache evicted.."); i.remove(); } } if (operatingMode != null && !operatingMode.equalsIgnoreCase("3")) { logger.info("Starting the work method"); //wpt.setPriority(Thread.MAX_PRIORITY); //wpt.start(); wpt.work(); startedThread = true; logger.info("Done starting working publication thread..."); } if (operatingMode != null && operatingMode.equalsIgnoreCase("3") && pt != null) //If published-mode we update entire cache to be sure.. { int size = 0; synchronized (notifications) { size = notifications.size(); } if (size > 0) { logger.info("Starting selective publication thread [" + pt.getClass().getName() + "]"); pt.setPriority(Thread.MIN_PRIORITY); pt.start(); startedThread = true; logger.info("Done starting publication thread..."); } } if (!startedThread) RequestAnalyser.getRequestAnalyser().setBlockRequests(false); t.printElapsedTime("evict done"); logger.info("evictWaitingCache stop"); }