LinkedBlockingQueue是否适合以下需求:
1. insert strings (maximum 1024 bytes) into the queue at a very high rate
2. every x inserts or based on a timed interval, flush items into mysql
在清空队列时,我正在查看API:http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/LinkedBlockingQueue.html
我在想drainTo是否是一个好选择,因为在清空前,我需要进行聚合。
所以我将从队列中取出项目,然后迭代和聚合,最后写入mysql。
这对每秒多达10K个写入器是否适用?
我需要考虑任何锁定/同步问题吗,还是已经处理了?
我将把这个linkedblockingqueue作为concurrenthashmap中的值存储。
项目将永远不会从哈希映射中删除,仅在不存在时被插入,并且如果存在,则将附加到队列末端。
ConcurrentHashMap
?这个 map 中的键是什么? - Gray