我试图在mysql数据库中使用两个不同的线程插入。正在通过准备好的声明进行插入。插入500批次。
// g1是实现runnable
的类访问的对象全局 ExecutorService executor = Executors.newCachedThreadPool();
Callable< Map<String, Set<String>>> callable2 = new PolyStrain();
Callable<Map<String, Phenotype>> callable3 = new DataPolymor();
g1.kol=new HashMap<String, Set<String>>();
g1.mapPheno = new HashMap<String, Phenotype>();
Future<Map<String, Set<String>>> future = executor.submit(callable2); // hashmap of allele and strains
Future<Map<String, Phenotype>> future1 = executor.submit(callable3); //hashmap of allele and chro,location
g1.kol = future.get();
System.out.println(g1.kol.size());
g1.mapPheno= future1.get();
System.out.println(g1.mapPheno.size());
executor.shutdown();
InsertStrain dp1 = new InsertStrain(); //data entry for allele and strain and frequency
Thread t1= new Thread(dp1);
t1.start();
InsertPheno ip1 = new InsertPheno();
Thread t2 = new Thread(ip1);
t2.start();
我面临的问题是,第二个线程已启动,但是它不适用于插入。线程dp1完成其任务。 完成dp1后,抛出以下内容:
Lock wait timeout exceeded; try restarting transaction
我已经设置了
mysql> SELECT @@GLOBAL.tx_isolation, @@tx_isolation, @@session.tx_isolation;
此外,
mysql> set innodb_lock_wait_timeout=100
我想知道,即使线程2开始,为什么它不会开始插入? 任何帮助都将受到高度赞赏。 非常感谢提前。