美文网首页
获取线程TiD与进程PiD

获取线程TiD与进程PiD

作者: 码畜笔记 | 来源:发表于2020-01-11 16:41 被阅读0次


/**

        * Returns the identifier of this process's user.

        * 返回此进程的用户的标识符。

        */

        Log.e(TAG, "Process.myUid() = " + android.os.Process.myTid());

        /**

        * Returns the identifier of this process, which can be used with

        * killProcess and sendSignal.

        * 返回此进程的标识符,可用于进程和发送信号。

        */

        Log.e(TAG, "Process.myPid() = " + android.os.Process.myPid());

        /**

        * Returns the identifier of the calling thread, which be used with

        * setThreadPriority(int, int).

        * 返回调用线程的标识符,该标识符与StTeRead优先级(int,int)。

        */

        Log.e(TAG, "Process.myTid() = " + android.os.Process.myTid());

        /**

        * Returns the thread's identifier. The ID is a positive long generated

        * on thread creation, is unique to the thread, and doesn't change

        * during the lifetime of the thread; the ID may be reused after the

        * thread has been terminated.

        * 返回线程的标识符。ID是正长生成的关于线程创建,对于线程是唯一的,并且不会改变。

        * 在线程的生存期内,ID可以在线程已被终止。

        */

        //返回当前线程的id

        Log.e(TAG, "Thread.currentThread().getId() = " + Thread.currentThread().getId());

        //返回主线程的id

        Log.e(TAG, "getMainLooper().getThread().getId() = " + getMainLooper().getThread().getId());

        //返回当前应用的主线程id

        Log.e(TAG, "((getApplication().getMainLooper()).getThread()).getId() = "

                                + ((getApplication().getMainLooper()).getThread()).getId());

        /**

        * Return the identifier of the task this activity is in. This

        * identifier will remain the same for the lifetime of the activity.

        * 返回此活动正在执行的任务的标识符。这个标识符对于活动的生存期将保持不变。

        */

        //返回activity任务栈的id

        Log.e(TAG, "getTaskId() = " + getTaskId());

        /**

        * The kernel user-ID that has been assigned to this application;

        * currently this is not a unique ID (multiple applications can have the

        * same uid).

        * 已分配给该应用程序的内核用户ID;这不是一个唯一的ID(多个应用程序可以有相同的UID)。

        */

        Log.e(TAG, "getApplicationInfo().uid = " + getApplicationInfo().uid);

        /**

        * The name of the process this application should run in. From the

        * "process" attribute or, if not set, the same as packageName.

        * 此应用程序应运行的进程的名称。从“进程”属性,或如果没有设置,与PACKAGEName相同。

        */

        Log.e(TAG, "getApplicationInfo().processName = "  + getApplicationInfo().processName);

        /**

        * 得到当前activity的信息

        */

        Log.e(TAG, "Activity.toString:"+this.toString());

        new Thread(new Runnable() {

            @Override

            public void run() {

                //返回当前线程的id

                // TODO Auto-generated method stub

                Log.e(TAG, "Thread.currentThread().getId() = "

                        + Thread.currentThread().getId());

            }

        }).start();

相关文章

  • 获取线程TiD与进程PiD

    /** * Returns the identifier of this process's user....

  • 定位CPU占用过高

    1、ps -ef|grep ''获取 进程pid 2、top -Hp pid查看该进程下占用高的线程的Pid(下面...

  • 进程和线程补充

    进程与线程标识 进程pid 注意:进程pid在start之后才分配。 线程ident 注意:所以线程ident在s...

  • Linux中找出Java程序占用大量CPU的元凶

    原理 通过top找到占用CPU高的进程pid,通过ps找到该进程中占用CPU高的线程tid,最后通过jstack找...

  • CPU占用问题排查

    top 查到pid ps aux|grep pid 显示线程列表 ps -mp pid -o THREAD,tid...

  • task_struct结构

    进程标识符(PID) Unix系统通过pid来标识进程,linux把不同的pid与系统中每个进程或轻量级线程关联,...

  • Linux 常用命令二

    通过进程号获取进程启动路径 通过进程号获取进程启动路径 获取进程PID,然后进入/proc/进程PID ls -l...

  • jvm 定位cpu热点堆栈信息

    1. 使用top命令查看占用cpu过高进程,获取PID 2. 使用top -Hp命令获取进程中线程信息(其中H:线...

  • pidstat

    列出pid对应的每个线程占用cpu的情况pidstat -t -p ${pid} 输出格式:TGID TID %u...

  • cpu过高

    1.获取Java进程的pid jps -l 2.查看占用cpu高,且占用时间长的线程 ps -mp pid -o ...

网友评论

      本文标题:获取线程TiD与进程PiD

      本文链接:https://www.haomeiwen.com/subject/mpcbactx.html