Nikunj Patel
Nikunj Patel

Reputation: 22076

Difference Between myPid & myTid & myUid

Difference between ::

int pid = android.os.Process.myPid();
android.os.Process.killProcess(pid);
             //And 
int pid = android.os.Process.myTid();
android.os.Process.killProcess(pid);
             //And  
int pid = android.os.Process.myUid();
android.os.Process.killProcess(pid);

Upvotes: 4

Views: 4297

Answers (1)

spatulamania
spatulamania

Reputation: 6663

Only the first one will get the actual process Id and properly kill the process. The other examples will fail because you're passing the wrong process id to killProcess().

From the docs:

myPid() - Returns the identifier of this process, which can be used with killProcess(int) and sendSignal(int, int).

myTid() - Returns the identifier of the calling thread, which be used with setThreadPriority(int, int).

myUid() - Returns the identifier of this process's user.

killProcess(int pid) - Kill the process with the given PID.

See the docs for more details. http://developer.android.com/reference/android/os/Process.html

Here are some additional links:

Upvotes: 6

Related Questions