Java-Feature


Java Feature

package com.lhq.Main;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.Feature;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;

/**
 * @author 刘华强
 * @Classname main
 * @Description TODO
 * @Date 06/12/2020 14:08
 */
public class main {
    public static void main(String[] args) throws InterruptedException, ExecutionException, TimeoutException {
        ExecutorService pool = Executors.newCachedThreadPool();

        Future<String> task1 = pool.submit(new Callable<String>() {
            @Override
            public String call() throws Exception {
                return "ok";
            }
        });

        Future<String> submit1 = pool.submit(() -> {
            Thread.sleep(3000);
            return "123";
        });
        Future<Integer> submit2 = pool.submit(() -> {
            Thread.sleep(5000);
            return 234;
        });
        Future<Long> submit3 = pool.submit(() -> 345L);
        Integer a = 1;
        Integer b = 2;
        Future<Integer> submit4 = pool.submit(() -> a + b);

        long s = System.currentTimeMillis();
        if("123".equals(submit1.get())) {
            System.out.println("是123啊");
        }
        submit2.get();
        System.out.println(System.currentTimeMillis()-s);
        pool.shutdown();
    }
}

文章作者: anlen123
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 anlen123 !
 上一篇
ES-Java-API ES-Java-API
···1.ES Java APIhttps://www.bilibili.com/video/BV1Qz411e7yx?t=417&p=13 1.1 创建索引@SpringBootTest class Test2 { @Au
2020-12-24 anlen123
下一篇 
arch安装教程 arch安装教程
ArchLinux记一次装设置字体大小 setfont /usr/share/kbd/consolefonts/LatGrkCyr-12x22..psfu.gz 查看是不uif打开的 ls /sys/firmware/efi/efivars
2020-12-24 anlen123
  目录