package com.github.herowzz.dayIdGen.test;

import com.alibaba.druid.pool.DruidDataSource;
import com.github.herowzz.dayIdGen.embed.DayIdGen;
import com.github.herowzz.dayIdGen.embed.dao.IdDao;

public class TestDayIdGen {

	public static final String DRIVER_MYSQL = "com.mysql.cj.jdbc.Driver";
	public static final String URL = "jdbc:mysql://127.0.0.1:3306/test111?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&useLegacyDatetimecode=false&serverTimezone=PRC";
	public static final String USER = "root";
	public static final String PASSWORD = "caiot";

	public static void main(String[] args) throws Exception {
		DruidDataSource dataSource = new DruidDataSource();
		dataSource.setUrl(URL);
		dataSource.setUsername(USER);
		dataSource.setPassword(PASSWORD);
		dataSource.setInitialSize(1);
		dataSource.setMinIdle(1);
		dataSource.setMaxActive(20);
		dataSource.setMaxWait(60000);
		dataSource.setTimeBetweenEvictionRunsMillis(60000);
		dataSource.setMinEvictableIdleTimeMillis(300000);
		dataSource.init();

		IdDao idDao = new IdDao();
		idDao.setDataSource(dataSource);

		DayIdGen idGen = new DayIdGen();
		idGen.setIdDao(idDao);
		idGen.setMinDigit(5);
		idGen.setPrefix("RK");
		idGen.setName("aaaaaaaa");

		for (int i = 0; i < 100; i++) {
			String id = idGen.getNextDateId();
			System.out.println(id);
		}
	}

}

@@ -38,16 +38,63 @@
 est;%0D%0A%0D%0A
+import java.util.concurrent.CountDownLatch;%0D%0A%0D%0A
 import c
@@ -1315,21 +1315,111 @@
 me(%22
-aaaaaaaa%22);%0D%0A
+ccc%22);%0D%0A%0D%0A%09%09CountDownLatch latch = new CountDownLatch(200);%0D%0A%09%09long begin = System.currentTimeMillis();
 %0D%0A%09%09
@@ -1438,17 +1438,17 @@
  0; i %3C 
-1
+2
 00; i++)
@@ -1451,16 +1451,93 @@
 i++) %7B%0D%0A
+%09%09%09new Thread(() -%3E %7B%0D%0A%09%09%09%09for (int j = 0; j %3C 10000; j++) %7B%0D%0A%09%09%09%09%09try %7B%0D%0A%09%09%09
 %09%09%09Strin
@@ -1567,16 +1567,19 @@
 eId();%0D%0A
+%09%09%09
 %09%09%09Syste
@@ -1600,17 +1600,329 @@
 id);%0D%0A%09%09
-%7D
+%09%09%09%7D catch (Exception e) %7B%0D%0A%09%09%09%09%09%09e.printStackTrace();%0D%0A%09%09%09%09%09%7D%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%09latch.countDown();%0D%0A%09%09%09%7D).start();%0D%0A%09%09%7D%0D%0A%09%09try %7B%0D%0A%09%09%09latch.await();%0D%0A%09%09%7D catch (InterruptedException e) %7B%0D%0A%09%09%09e.printStackTrace();%0D%0A%09%09%7D%0D%0A%09%09long end = System.currentTimeMillis();%0D%0A%09%09System.out.println(%22%E6%89%A7%E8%A1%8C%E8%80%97%E6%97%B6:%22 + (end - begin) / 1000 + %22s%22);
 %0D%0A%09%7D%0D%0A%0D%0A

add muti thread test case