1 / 17

CS-434: Object-Oriented Programming Using Java Week 8

CS-434: Object-Oriented Programming Using Java Week 8. Dr. Jesús Borrego Adjunct Faculty Regis University. Class Outline. Review of Final Project Key Terms Concurrency and Multithreading Questions on Final Final Exam Questions?. Key Terms. Multithread – múltiples hilos Thread - Hilo.

zia-york
Download Presentation

CS-434: Object-Oriented Programming Using Java Week 8

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. CS-434: Object-Oriented Programming Using JavaWeek 8 Dr. Jesús Borrego Adjunct Faculty Regis University

  2. Class Outline Review of Final Project Key Terms Concurrency and Multithreading Questions on Final Final Exam Questions?

  3. Key Terms Multithread – múltiples hilos Thread - Hilo

  4. Concurrency Performing more than one task at the same time Can be done either by multiple processes managed by the OS or by multiple threads running under a single process We’ll examine Java’s approach to threads

  5. Concurrency in multiple CPUs

  6. Threads

  7. Thread States

  8. Thread Priorities • Public static final int MAX_PRIORITY • Defines the highest priority that can be assigned to a thread • Public static final int MIN_PRIORITY • Defines the lowest priority that can be assigned to a thread • Public static final int NORM_PRIORITY • Defines the normal, default priority that is assigned to a thread

  9. Thread Priorities (Cont’d) • On Windows, the priorities typically range from 1-10, (10 > 1, 5 is normal) • Other platforms use different values • Highest priority threads execute before lower priority • i.e., threads of lower priority must wait for higher priority threads to relinquish the CPU before they (the lower priority threads) can run. • Threads of the same priority are allocated CPU time slices in a “round robin” fashion.

  10. Thread Management • Java provides three techniques for creating threads: • class inheritance • interface implementation • timer for scheduled events • Thread Class

  11. Thread Class The two most important methods of class Thread are run() and start() Method run() is used to define the high-level coding logic of a thread, which is provided by you, the developer, either through inheritance or with an implementation of interface Runnable When method start() is called, it notifies the JVM to launch a new thread whose entry point is method run()

  12. Thread Inheritance Create a class that extends Thread In main:

  13. Activity 1 Port scan and threads in Java (16:50 min): http://www.youtube.com/watch?v=FpT2fJlBSjU

  14. Questions on material covered

  15. Demo of Final Project

  16. Final Exam Due Tuesday by midnight Submit to WorldClass as a single zip file containing the Word document and a folder with the entire NetBeans project

  17. Questions?

More Related