Пример #1
0
 @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRES_NEW)
 public void write() throws Exception {
   User user = userMapper.findByUserName("first");
   System.out.println(
       String.format("当前write线程%s,更新用户信息,用户%s,时间戳%tc", Thread.currentThread(), user, new Date()));
   user.setAge("100");
   userMapper.updateUserById(user);
   System.out.println(
       String.format(
           "当前write线程%s,更新用户信息完成,用户%s,时间戳%tc", Thread.currentThread(), user, new Date()));
   try {
     TimeUnit.SECONDS.sleep(2);
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
   user = userMapper.findByUserName("first");
   System.out.println(
       String.format("当前write线程%s,更新用户信息,用户%s,时间戳%tc", Thread.currentThread(), user, new Date()));
 }