Example usage for android.os Process THREAD_PRIORITY_LOWEST

List of usage examples for android.os Process THREAD_PRIORITY_LOWEST

Introduction

In this page you can find the example usage for android.os Process THREAD_PRIORITY_LOWEST.

Prototype

int THREAD_PRIORITY_LOWEST

To view the source code for android.os Process THREAD_PRIORITY_LOWEST.

Click Source Link

Document

Lowest available thread priority.

Usage

From source file:com.grazerss.EntryManager.java

private void runSimpleJob(final String name, final Runnable runnable, final Handler handler) {
    new Thread(new Runnable() {
        public void run() {
            try {
                runJob(new Job(name, EntryManager.this) {

                    @Override/*from   ww w.  j  a  va 2  s  . c o  m*/
                    public void run() throws Exception {

                        try {
                            Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);

                            synchronized (this) {
                                if (isModelCurrentlyUpdated()) {
                                    return;
                                }
                                lockModel(name);
                            }
                            runnable.run();
                        } finally {
                            synchronized (this) {
                                unlockModel(name);
                            }
                        }
                    }
                });
            } catch (final Throwable e) {
                if (handler != null) {
                    handler.post(new Runnable() {

                        public void run() {
                            showExceptionToast(name, e);
                        }
                    });
                }
            }

        }
    }).start();
}

From source file:com.newsrob.EntryManager.java

public void doUnsubscribeFeed(String feedAtomId) {
    try {/*from  ww  w  .  ja va 2s . com*/
        Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);

        synchronized (this) {
            if (isModelCurrentlyUpdated())
                return;
            lockModel("EM.requestUnsubscribeFeed");
        }
        if (canFeedBeUnsubscribed(feedAtomId)) {
            databaseHelper.addFeed2Unsubscribe(feedAtomId);
            DBQuery dbq = prepareMarkFeedReadQuery(feedAtomId);
            if (dbq != null)
                doMarkAllRead(dbq);
        }
    } finally {
        synchronized (this) {
            unlockModel("EM.requestUnsubscribeFeed");
        }
    }

}