package com.sunda.spmsweb.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 * @program: spms
 * @description:
 * @author: Wayne Wu
 * @create: 2021-07-08 12:21
 **/

public class Test1 {
    public static void main(String[] args) throws ParseException {
        DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");

        System.out.println(fmt.parse("2021-07-11").getTime() - fmt.parse("2021-07-12").getTime());
        System.out.println(fmt.parse("2021-07-13").getTime() - fmt.parse("2021-07-12").getTime());
        System.out.println(fmt.parse("2021-07-12").getTime() - fmt.parse("2021-07-12").getTime());

//        线程安全测试
//        System.out.println("使用关键字synchronized");
//        SyncThread syncThread = new SyncThread();
//        Thread thread1 = new Thread(syncThread, "SyncThread1");
//        Thread thread2 = new Thread(syncThread, "SyncThread2");
//        Thread thread3 = new Thread(syncThread, "SyncThread3");
//        thread1.start();
//        thread2.start();
//        thread3.start();
    }
}
class SyncThread implements Runnable {
    private static int count;
    public SyncThread() {
        count = 0;
    }
    @Override
    public void run() {
        synchronized (this){
            for (int i = 0; i < 10; i++) {
                try {
                    System.out.println("线程名:"+Thread.currentThread().getName() + ": " + (count++));
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    public int getCount() {
        return count;
    }
}