Java 线程机制

来源:互联网 发布:非典是基因武器 知乎 编辑:程序博客网 时间:2024/05/05 07:59

1.进程是一个可执行的,一个运行的程序,是一个静态的概念。现在的操作系统支持多进程和多线程

2.线程是一个进程中不同的执行路径,每个进程必须有一个主线程

3.一个CPU,在同一个时间点上只能支持一个线程运行。

4.多线程的真正含义是:系统是多CPU,多核处理器

5.创建线程thread,启动线程。

6有两种方式创建一个线程,继承thread类,实现runnable接口。

Constructor SummaryThread()
          Allocates a new Thread object.Thread(Runnable target)
          Allocates a new Thread object.Thread(Runnable target, String name)
          Allocates a new Thread object.Thread(String name)
          Allocates a new Thread object.Thread(ThreadGroup group, Runnable target)
          Allocates a new Thread object.Thread(ThreadGroup group, Runnable target, String name)
          Allocates a new Thread object so that it has target as its run object, has the specified name as its name, and belongs to the thread group referred to by group.Thread(ThreadGroup group, Runnable target, String name, long stackSize)
          Allocates a new Thread object so that it has target as its run object, has the specified name as its name, belongs to the thread group referred to by group, and has the specified stack size.

Thread(ThreadGroup group, String name)
          Allocates a new Thread object.

 

 

7.线程启动通过调用thread的start方法来调用。

原创粉丝点击