1 / 6

第9章 线程与同步

第9章 线程与同步. 面向对象的程序设计与 JAVA 娄不夜 王利 编著 主讲:胡传福 E-mail:hucf@dgut.edu.cn. 线程创建. 实现 Runnable 接口 提供一个实现 Runnable 接口的类,实现 run() 方法. 创建该类的一个实例,并将其作为创建 Thread 类对象的参数. 调用 Thread 类的对象的 start() 方法来启动线程. 线程创建. 扩展 Thread 类 定义 Thread 类的一个子类,实现 run() 方法. 创建该子类的一个对象. 通过该对象调用 start() 方法. 线程创建. 线程是对象.

brenna
Télécharger la présentation

第9章 线程与同步

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第9章 线程与同步 面向对象的程序设计与JAVA 娄不夜 王利 编著 主讲:胡传福 E-mail:hucf@dgut.edu.cn Chapter 9

  2. 线程创建 • 实现Runnable接口 • 提供一个实现Runnable接口的类,实现run()方法. • 创建该类的一个实例,并将其作为创建Thread类对象的参数. • 调用Thread类的对象的start()方法来启动线程. Chapter 9

  3. 线程创建 • 扩展Thread类 • 定义Thread类的一个子类,实现run()方法. • 创建该子类的一个对象. • 通过该对象调用start()方法. Chapter 9

  4. 线程创建 • 线程是对象. • 线程通过执行特定对象的特定方法代码来完成相应的任务. • 线程必需通过start()方法启动. Chapter 9

  5. 线程控制 • 9.2 通过thread类定义的方法来对线程进行控制. Chapter 9

  6. 互斥与同步 • 临界段资源问题 Chapter 9

More Related