Exemplo n.º 1
0
 /** {@inheritDoc} */
 @Override
 public void insertUsers(final Integer size) {
   log.info("Create {} users", size);
   // lock to update max user id
   try {
     lock.writeLock().lock();
     userDao.insertUsers(IntStream.rangeClosed(1, size).boxed().collect(Collectors.toList()));
     this.max = userDao.max();
   } finally {
     lock.writeLock().unlock();
   }
   log.info("{} users are inserted. Max id is {}", size, max);
 }
Exemplo n.º 2
0
 public UserServiceImpl(final UserDao userDao) {
   this.userDao = userDao;
   try {
     lock.writeLock().lock();
     this.max = userDao.max();
   } finally {
     lock.writeLock().unlock();
   }
 }