Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7530657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:58:12+00:00 2026-05-30T04:58:12+00:00

I’m trying to change priority of main thread using android.os.Process.setThreadPriority() . I have log

  • 0

I’m trying to change priority of main thread using android.os.Process.setThreadPriority(). I have log messages before and after priority changing, here is code:

public class TestActivity extends Activity {
    public final String TAG="TestActivity";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        int tid=(int)Thread.currentThread().getId();
        Log.d(TAG,"priority before change = " + android.os.Process.getThreadPriority(tid));
        Log.d(TAG,"priority before change = "+Thread.currentThread().getPriority());
        android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_DISPLAY);
        Log.d(TAG,"priority after change = " + android.os.Process.getThreadPriority(tid));
        Log.d(TAG,"priority after change = " + Thread.currentThread().getPriority());
    }
}

And I get the following output:

priority before change (getThreadPriority) = 0
priority before change (currentThread().getPriority) = 5
priority after change (getThreadPriority) = 0
priority after change (currentThread().getPriority) = 5

It means that priority didn’t change, whatever method I use to evaluate it.
android.os.Process.THREAD_PRIORITY_DISPLAY = -4, so after changing my ouput should equal -4, why it remains the same? Why android.os.Process.setThreadPriority() has no effect?

P.S. I read google docs about threads, but I didn’t come across any issues explaining difference between android.os.Process.getThreadPriority() and Thread.currentThread().getPriority(). Why these methods return different values?

P.P.S. Thread.currentThread().setPriority() works fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:58:14+00:00Added an answer on May 30, 2026 at 4:58 am

    You are using the wrong ThreadID for your check.

    To get the correct id you have to use android.os.Process.myTid();

    Fixed code:

    package mypackage.test;
    import android.app.Activity;
    import android.os.Bundle;
    import android.util.Log;
    
    public class TestActivity extends Activity {
        public final String TAG="TestActivity";
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            int tid=android.os.Process.myTid();
    
            Log.d(TAG,"priority before change = " + android.os.Process.getThreadPriority(tid));
            Log.d(TAG,"priority before change = "+Thread.currentThread().getPriority());
            android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_DISPLAY);
            Log.d(TAG,"priority after change = " + android.os.Process.getThreadPriority(tid));
            Log.d(TAG,"priority after change = " + Thread.currentThread().getPriority());
        }
    }
    

    Log output:

    priority before change = 0
    priority before change = 5
    priority after change = -4
    priority after change = 5
    

    For further reference:

    http://developer.android.com/reference/android/os/Process.html#myTid()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.