start_thread 中的线程在 start_activity 线程(主线程)在信号量上休眠时访问 packetList 是否安全。如果没有,那么我如何在它们之间共享资源,请注意访问权限只会被读取,而 packetList 不会被更改。
class A{
Vector<packet> packetList;
A()
{
//packetList initialized here
}
void start_thread()
{
//start a thread here
}
void start_activity()
{
while(true)
{
//possibly sleep on semephore
//do work
}
}
}