<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=Android_-_Thread_Priority</id>
	<title>Android - Thread Priority - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.stephanschlegel.de/index.php?action=history&amp;feed=atom&amp;title=Android_-_Thread_Priority"/>
	<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=Android_-_Thread_Priority&amp;action=history"/>
	<updated>2026-05-09T05:43:37Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Wikizone</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=Android_-_Thread_Priority&amp;diff=19676&amp;oldid=prev</id>
		<title>134.3.241.116 am 4. März 2013 um 19:40 Uhr</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=Android_-_Thread_Priority&amp;diff=19676&amp;oldid=prev"/>
		<updated>2013-03-04T19:40:28Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 4. März 2013, 19:40 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l57&quot; &gt;Zeile 57:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 57:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So currently Thread.setPriority should actually do the same as Process.setThreadPritority, using the smaller Java priority scale, the mapping of prioritys is defined in kNiceValues at vm/Thread.c&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So currently Thread.setPriority should actually do the same as Process.setThreadPritority, using the smaller Java priority scale, the mapping of prioritys is defined in kNiceValues at vm/Thread.c&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;However, using &amp;#039;&amp;#039;&amp;#039;Thread.setPriority()&amp;#039;&amp;#039;&amp;#039; you are using a &amp;#039;&amp;#039;&amp;#039;scale of 0-10&amp;#039;&amp;#039;&amp;#039; and on &amp;#039;&amp;#039;&amp;#039;Process.setThreadPriority()&amp;#039;&amp;#039;&amp;#039; you are using the nice &amp;#039;&amp;#039;&amp;#039;scale (+&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;/- 20&lt;/del&gt;&amp;#039;&amp;#039;&amp;#039;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;)&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;However, using &amp;#039;&amp;#039;&amp;#039;Thread.setPriority()&amp;#039;&amp;#039;&amp;#039; you are using a &amp;#039;&amp;#039;&amp;#039;scale of 0-10&amp;#039;&amp;#039;&amp;#039; and on &amp;#039;&amp;#039;&amp;#039;Process.setThreadPriority()&amp;#039;&amp;#039;&amp;#039; you are using the nice &amp;#039;&amp;#039;&amp;#039;scale &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;-20 &lt;/ins&gt;(&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;highest to /&lt;/ins&gt;+ &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;19 (lowest)&lt;/ins&gt;&amp;#039;&amp;#039;&amp;#039;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>134.3.241.116</name></author>
	</entry>
	<entry>
		<id>https://wiki.stephanschlegel.de/index.php?title=Android_-_Thread_Priority&amp;diff=19675&amp;oldid=prev</id>
		<title>134.3.241.116: Die Seite wurde neu angelegt: „Beispiel: &lt;pre&gt; package mypackage.test; import android.app.Activity; import android.os.Bundle; import android.util.Log;  public class TestActivity extends Activit…“</title>
		<link rel="alternate" type="text/html" href="https://wiki.stephanschlegel.de/index.php?title=Android_-_Thread_Priority&amp;diff=19675&amp;oldid=prev"/>
		<updated>2013-03-04T19:36:13Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „Beispiel: &amp;lt;pre&amp;gt; package mypackage.test; import android.app.Activity; import android.os.Bundle; import android.util.Log;  public class TestActivity extends Activit…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Beispiel:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package mypackage.test;&lt;br /&gt;
import android.app.Activity;&lt;br /&gt;
import android.os.Bundle;&lt;br /&gt;
import android.util.Log;&lt;br /&gt;
&lt;br /&gt;
public class TestActivity extends Activity {&lt;br /&gt;
    public final String TAG=&amp;quot;TestActivity&amp;quot;;&lt;br /&gt;
    @Override&lt;br /&gt;
    public void onCreate(Bundle savedInstanceState) {&lt;br /&gt;
        super.onCreate(savedInstanceState);&lt;br /&gt;
        setContentView(R.layout.main);&lt;br /&gt;
&lt;br /&gt;
        int tid=android.os.Process.myTid();&lt;br /&gt;
&lt;br /&gt;
        Log.d(TAG,&amp;quot;priority before change = &amp;quot; + android.os.Process.getThreadPriority(tid));&lt;br /&gt;
        Log.d(TAG,&amp;quot;priority before change = &amp;quot;+Thread.currentThread().getPriority());&lt;br /&gt;
        android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_DISPLAY);&lt;br /&gt;
        Log.d(TAG,&amp;quot;priority after change = &amp;quot; + android.os.Process.getThreadPriority(tid));&lt;br /&gt;
        Log.d(TAG,&amp;quot;priority after change = &amp;quot; + Thread.currentThread().getPriority());&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
priority before change = 0&lt;br /&gt;
priority before change = 5&lt;br /&gt;
priority after change = -4&lt;br /&gt;
priority after change = 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2 Möglichkeiten: http://stackoverflow.com/questions/5198518/whats-the-difference-between-thread-setpriority-and-android-os-process-setthre&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Runnable r = ...;&lt;br /&gt;
&lt;br /&gt;
Thread  thread = new Thread(r);&lt;br /&gt;
thread.setPriority((Thread.MAX_PRIORITY + Thread.NORM_PRIORITY) / 2);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    Runnable r = ...&lt;br /&gt;
    Thread thread = new Thread( new Runnable() {&lt;br /&gt;
       public void run() {&lt;br /&gt;
         android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_MORE_FAVORABLE);&lt;br /&gt;
         r.run();&lt;br /&gt;
       }&lt;br /&gt;
    });&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kommentare:&lt;br /&gt;
&lt;br /&gt;
The current Dalvik implementation seems to map Java Threads ony by one to the underlying linux system PTHREADs like you say. All Threads of all apps belong on the same thread group on the system, so every Thread competes with all Threads of all apps.&lt;br /&gt;
&lt;br /&gt;
So currently Thread.setPriority should actually do the same as Process.setThreadPritority, using the smaller Java priority scale, the mapping of prioritys is defined in kNiceValues at vm/Thread.c&lt;br /&gt;
&lt;br /&gt;
However, using &amp;#039;&amp;#039;&amp;#039;Thread.setPriority()&amp;#039;&amp;#039;&amp;#039; you are using a &amp;#039;&amp;#039;&amp;#039;scale of 0-10&amp;#039;&amp;#039;&amp;#039; and on &amp;#039;&amp;#039;&amp;#039;Process.setThreadPriority()&amp;#039;&amp;#039;&amp;#039; you are using the nice &amp;#039;&amp;#039;&amp;#039;scale (+/- 20&amp;#039;&amp;#039;&amp;#039;).&lt;/div&gt;</summary>
		<author><name>134.3.241.116</name></author>
	</entry>
</feed>