我有要插入Cassandra数据库的数据(网络数据包)!
不幸的是,我的应用程序需要大约 1 分钟才能插入 10000 个数据包!
正在找有没有人可以帮我操作java多线程概念加速插入!这是我的代码:
PcapPacketHandler<String> jpacketHandler;
jpacketHandler = new PcapPacketHandler<String>() {
GestionPacketDAO g1;
int row=0;
public void nextPacket(PcapPacket packet, String user) {
row++;
String s = packet.toHexdump();
try {
g1 = new GestionPacketDAO();
g1.Insert(s, row);// Insert is the function which inserts data into database
}
catch (InvalidRequestException exg) {
Logger.getLogger(AccueilInsertion.class.getName()).log(Level.SEVERE, null, exg);
}
catch (TException exg) {
Logger.getLogger(AccueilInsertion.class.getName()).log(Level.SEVERE, null, exg);
}
}
}