task1 - sarasayhi/hello-world GitHub Wiki

public class Test { public static void main(String[] args) { ExecutorService executor = Executors.newCachedThreadPool(); Task task = new Task(); Future result = executor.submit(task); executor.shutdown();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }
     
    System.out.println("主线程在执行任务");
     
    try {
        System.out.println("task运行结果"+result.get());
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
     
    System.out.println("所有任务执行完毕");
}

} class Task implements Callable{ @Override public Integer call() throws Exception { System.out.println("子线程在进行计算"); Thread.sleep(3000); int sum = 0; for(int i=0;i<100;i++) sum += i; return sum; } }

public static void main(String[] args) throws InterruptedException, ExecutionException{ ExecutorService fixedThreadPool = Executors.newFixedThreadPool(4); ConcurrentHashMap<Integer, Future> map = new ConcurrentHashMap(4); for (int i = 0; i < 4; i++) { map.put(i,fixedThreadPool.submit(() -> new Random().nextInt(100))); } fixedThreadPool.shutdown(); for (Map.Entry m:map.entrySet()){ Future f = (Future)m.getValue(); if (f.isDone()) { System.out.println(m.getKey() + "---" + f.get()); } } }

1.课程1到4的小作业:搭建一个基于servlet 3.0的hello world web工程 要求: (1)使用maven工程,编译、打包、发布 (2)使用纯servlet、jsp实现简单页面,后台需要应用到继承、多态、递归、多线程、文件读写等java基础知识 (3)体现filter技术、session、request和response的使用 (4)web-frament的特性应用 (5)最终和tomcat一起打包,并调整tomcat的jvm参数。

2.课程5到7的小作业:把第1个小作业改造成基于spring mvc和spring boot的两种工程。

3.课程8到11的小作业:在作业2的基于spring boot的工程基础上,结合orm框架进行增删改查实现、mq和缓存的使用、基于cxf的webservice和restful的发布和调用,生成第三方wsdl并调用,最后编写单元测试用例。

⚠️ **GitHub.com Fallback** ⚠️