我一直在 C++ 应用程序生活中寻找线程安全的唯一 id 生成,所以我创建了以下静态类。
class Utils {
public :
static int getUid();
};
int Utils::getUid() {
static std::atomic<std::uint32_t> uid;
uid = 0;
return ++uid;
}
Run Code Online (Sandbox Code Playgroud)
任何建议,这是正确的方法吗?
在我的Galaxy S III上,使用logcat可以经常看到该过程终止。
(adj 5),(adj 8),(adj 9)和(adj 10)是什么意思?
以下是设备logcat:-
I/ActivityManager( 2258): Process com.google.android.partnersetup (pid 32242) (adj 10) has died.
I/ActivityManager( 2258): Process com.metago.astro (pid 32446) (adj 10) has died.
D/dalvikvm(32602): WAIT_FOR_CONCURRENT_GC blocked 0ms
I/ActivityManager( 2258): Process com.google.android.gms (pid 32272) (adj 10) has died.
I/ActivityManager( 2258): Process com.whatsapp (pid 12041) (adj 8) has died.
D/KeyguardViewMediator( 2258): setHidden false
D/WindowManager( 2258): mInputFocus is not null.
I/ActivityManager( 2258): Process com.sec.spp.push (pid 19839) (adj 8) has died.
I/ActivityManager( 2258): Process com.test.happ.jiffy (pid 556) (adj …Run Code Online (Sandbox Code Playgroud)