多线程 - 线程池

一、Executor

执行者,是一个接口类,他有一个方法叫执行,那么执行的东西是 Runnable。

二、ExecutorService

是从Executor继承,除了去实现Executor可以去执行一个任务之外,还完善了整个任务执行器的一个生命周期,就拿线程池来举例子,一个线程池里面一堆的线程就是一堆的工人,执行完一个任务之后我这个线程怎么结束啊;
线程池定义了这样一些个方法:

  • void shutdown();//结束
  • List shutdownNow();//马上结束
  • boolean isShutdown();//是否结束了
  • boolean isTerminated();//是不是整体都执行完了
  • boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException;//等着结束,等多长时间,时间到了还不结束的话他 就返回false
  • Future submit(Callable task);
  • Future<?> submit(Runnable task);
  • List<Future> invokeAll(Collection<? extends Callable> tasks) throws InterruptedException;
  • T invokeAny(Collection<? extends Callable> tasks) throws InterruptedException, ExecutionException;

阅读更多

Angular入门

Angular 环境搭建

1、安装前准备工作:
1.1、安装nodejs
安装nodejs的计算机上面必须安装nodejs, 建议安装最新稳定版本
$ node -v
1.2、安装cnpm
npm可能安装包会失败,建议先用npm安装一下cnpm用淘宝镜像安装
$ npm install -g cnpm –registry=https://registry.npm.taobao.org

2、使用 npm/cnpm 命令安装 angular/cli (只需要安装一次)
$ npm install -g @angular/cli 或者 cnpm install -g @angular/cli

阅读更多