打开APP
未登录
开通VIP,畅享免费电子书等14项超值服
开通VIP
首页
好书
留言交流
下载APP
联系客服
【转】Android中的PID,UID,TID
techres
>《Android系统》
2012.02.13
关注
Android中的PID,UID,TID
分类:
Android
2011-10-12 10:01
177人阅读
评论
(1)
收藏
举报
Source code:
[java]
view plain
copy
print
?
package
com.inanwong.main;
import
android.app.Activity;
import
android.os.Bundle;
import
android.os.Process;
import
android.util.Log;
public
class
MainActivity
extends
Activity {
private
static
final
String TAG = MainActivity.
class
.getSimpleName();
/** Called when the activity is first created. */
@Override
public
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.main);
/**
* Returns the identifier of this process's user.
*/
Log.e(TAG,
"Process.myUid() = "
+ Process.myUid());
/**
* Returns the identifier of this process, which can be used with
* killProcess and sendSignal.
*/
Log.e(TAG,
"Process.myPid() = "
+ Process.myPid());
/**
* Returns the identifier of the calling thread, which be used with
* setThreadPriority(int, int).
*/
Log.e(TAG,
"Process.myTid() = "
+ 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.
*/
Log.e(TAG,
"Thread.currentThread().getId() = "
+ Thread.currentThread().getId());
Log.e(TAG,
"getMainLooper().getThread().getId() = "
+ getMainLooper().getThread().getId());
/**
* 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.
*/
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.
*/
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).
*/
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.
*/
Log.e(TAG,
"getApplicationInfo().processName = "
+ getApplicationInfo().processName);
new
Thread(
new
Runnable() {
@Override
public
void
run() {
// TODO Auto-generated method stub
Log.e(TAG,
"Thread.currentThread().getId() = "
+ Thread.currentThread().getId());
}
}).start();
}
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报
。
打开APP,阅读全文并永久保存
查看更多类似文章
猜你喜欢
类似文章
【热】
打开小程序,算一算2024你的财运
Android中使用多线程的各种姿势
android的Handler - 程序员之路 - 博客园
androidhandler多线程demo
EventBus事件总线
PC客户端与Android服务端的Socket同步通信(USB) - 吴家大少少的专栏 -...
Android 中三种使用线程的方法
更多类似文章 >>
生活服务
热点新闻
留言交流
回顶部
联系我们
分享
收藏
点击这里,查看已保存的文章
导长图
关注
一键复制
下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!
联系客服
微信登录中...
请勿关闭此页面
先别划走!
送你5元优惠券,购买VIP限时立减!
5
元
优惠券
优惠券还有
10:00
过期
马上使用
×