Queue通常与Thread配对执行, 保证消息按照顺序安全执行.
private Queue<byte[]> buffQueue = new ConcurrentLinkedQueue<>();
class DemoThread extends Thread {
@Override
public void run() {
try {
while (true) {
if (!buffQueue.isEmpty()) {
sdk.feedTransCn(readBuffer, len);
}
}cache{}
}
}
网友评论