Why myPid() and myTid() return the same value?

bluecrest 2011-09-06 09:36:53
MessengerServiceActivities.java is the file in android sample.
Locate in C:\android-sdk-windows\samples\android-8\ApiDemos\src\com\example\android\apis\app\ dir.

I add myPid() and myTid() in onCreate(), then i set a breakpoint at code System.out. I find pid and tid are the same value. I know the process id and thread id should not be the same in windows, Why myPid() and myTid() return the same value in android?

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int pid;
int tid;
pid = android.os.Process.myPid();
tid = android.os.Process.myTid();
System.out.println(pid +" "+ tid);

setContentView(R.layout.messenger_service_binding);
...全文
112 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
myPid():Returns the identifier of this process
myTid():Returns the identifier of the calling thread

This process contains only one main thread,so myPid() == myTid()

80,337

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧