java - Java中线程优先级到底是做什么的

标签 java android-asynctask thread-priority

我目前正在开发一个用java编写的android项目。 我有一个仪表板,可以从 cloudant 数据库查询数据并将数据呈现在图表上。然而,数据必须在收到后进行处理。
我有 4 个 AsyncTasks,它们同时(或应该)处理 doInBackground Override 方法中接收到的数据。过程非常慢,我尝试了该行

Thread.currentThread().setPriority(Thread.MAX_PRIORITY);

在每个 AsyncTask 中。
然而,4个AsynkTasks似乎都相继发生,这是由于将线程优先级更改为max所致吗?当线程优先级更改时,它是否会停止所有其他线程并仅继续处理该线程直到完成?

最佳答案

来自:https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html

Every thread has a priority. Threads with higher priority are executed in preference to threads with lower priority. Each thread may or may not also be marked as a daemon. When code running in some thread creates a new Thread object, the new thread has its priority initially set equal to the priority of the creating thread, and is a daemon thread if and only if the creating thread is a daemon.

(注意:此信息是通过在 Google 中搜索“java Thread.MAX_PRIORITY”并查看顶部结果找到的)

关于java - Java中线程优先级到底是做什么的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45306059/

相关文章:

java - Swing 中的 JTable

Android Dev - 运行 top 命令输出到 TextView

Android:AsyncTask 的优先级高于 Service

android - 更改线程优先级没有效果

android - 带有错误处理和进度对话框的通用 AsyncTask

Java-Thread.setPriority()错误: cannot find symbol (the period between Thread and setPriority)

java - 未命名的json数组到java

java - 将数据从 Kinesis 写入 S3

java - 如何在Java中对多维Arraylist "ArrayList<String[]>"进行排序?

java - 异步任务: Two values to AsyncTask and process in doInBackground