"Concurrent Programming" gets thread information from the command line

Source: Internet
Author: User

Command

ADB Shell PS

-T view information for a thread in a process-X view Utime and Stime-p View Properties-P View the scheduling policy, usually to see if an app is in front or background-C to see which CPU is executing the process name|pid filter by name or PID

Example

(1) View the thread with the package name Com.eat, which is the UI thread that the com.eat applies to.

adb shell ps-t |grep com.eat app_62 21964 127748 17012 ffffffff
00000000 S com.eat

UID:APP_62 (when the program is installed, the system is assigned.) Linux is a multiuser system, and in Android, a user is quite an application. )

pid:21964 (Process ID)

ppid:141 (This is the zygote process, because all of the Android apps are "hatched" from this process.) )

Alternatively, you can use DDMS to view information about the process.

(2) View all threads in the app_62 application.

adb shell ps-t |grep app_62 app_62 21964 127748 17012 ffffffff   00000000 S com.eat
app_62    21965 21 964 127748 17012 Ffffffff 00000000 S heapworker app_62 21966 21964 127748 17012 ffffffff 00000000    S GC
app_62<  c8/>21967 21964 127748 17012 ffffffff 00000000 S Signal catcher app_62 21968 21964 127748 17012 ffffffff    00000000 S JDWP
app_62    21969 21964 127748 17012 ffffffff 00000000 S Compiler app_62 21970 21964 127748 17012    F Fffffff 00000000 S Binder thread # app_62 21971 21964 127748 17012 ffffffff \ 00000000    s Binder Thread #

A new application consists of no more than 10 threads, most of which are dalvik internal threads. From an application perspective, you don't need to care about them.

All other threads except Com.eat are Ppid 21966, which is com.eat pid. This is because these threads are hatched from the UI thread.

There are 3 threads to care about, respectively:

app_62    21964   127748 17012 ffffffff 00000000 S com.eat
app_62 21970 21964 127748 17012 ffffffff    000000 s Binder Thread #
app_62    21971 21964 127748 17012 ffffffff 00000000 S Binder Thread #

It is not hard to see that com.eat is a UI thread, and another 2 binder threads are used to invoke some services of the system, one is Applicationthead, the other is VIEWROO.W object.


Resources

http://blog.csdn.net/manoel/article/details/39500351

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.