Ejemplo n.º 1
0
 @Transactional(isolation = Isolation.SERIALIZABLE, propagation = Propagation.REQUIRES_NEW)
 public void readBatch() throws Exception {
   List<User> users1 = userMapper.findByAge("10");
   System.out.println(
       String.format(
           "当前readBatch线程%s,读取用户信息,用户%s,时间戳%tc",
           Thread.currentThread(), ArrayUtils.toString(users1.toArray()), new Date()));
   try {
     TimeUnit.SECONDS.sleep(5);
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
   List<User> users2 = userMapper.findByAge("10");
   System.out.println(
       String.format(
           "当前readBatch线程%s,读取用户信息完成,用户%s,时间戳%tc",
           Thread.currentThread(), ArrayUtils.toString(users2.toArray()), new Date()));
 }