Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

I’m working on an android project which queries from a cloud database. The received database has to be processed before it renders it on the graph. I’ve 4 AsyncTasks to process, but it is too slow. So I tried the below code: 

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

 

Can anyone tell me exactly how thread priority works in Java? 

1 Answer

0 votes
by (19.7k points)

This is what oracle says about thread priority: 

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.

For further reference: https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html

Interested in Java? Check out this Java Certification by Intellipaat.  

Related questions

0 votes
1 answer
0 votes
1 answer
asked Nov 20, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
0 votes
1 answer
asked Jul 31, 2019 in Java by noah kapoor (5.3k points)

Browse Categories

...