3089589

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2013年3月26日

摘要: 当一张表的多个字段没有唯一索引时,想要在sql语句中加上判断达到不插入重复记录的目的,可以使用mysql的dualINSERT INTO book_chapter_del(book_id, chapter_id,status)SELECT 20049198, 1000930, 0FROM dualWHERE not exists (select * from book_chapter_delwhere book_id = 20049198 and chapter_id=1000930) limit 1;select express [from dual]; mysql总是作为返回该表达式值的. 阅读全文
posted @ 2013-03-26 09:24 liangge0218 阅读(241) 评论(0) 推荐(0)

摘要: 最近在工作中有一个需求,要求N个子模块线程同时启动,等这N个子模块线程都完成后,再启动一个线程进行一些收尾工作,Java并发包中CountDownLatch与CyclicBarrier都可以达到此要求。CountDownLatch使用场景如下:public class Test {public static void main(String[] args) throws Exception{ Room r = new Room();new Thread(r).start(); r.startLatch.countDown(); }}class Room imp... 阅读全文
posted @ 2013-03-26 09:24 liangge0218 阅读(216) 评论(0) 推荐(0)