* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Chap 7 - UTRGV Faculty Web
Survey
Document related concepts
Java (programming language) wikipedia , lookup
Abstraction (computer science) wikipedia , lookup
Structured programming wikipedia , lookup
Java performance wikipedia , lookup
Join-pattern wikipedia , lookup
Falcon (programming language) wikipedia , lookup
Go (programming language) wikipedia , lookup
Name mangling wikipedia , lookup
Object-oriented programming wikipedia , lookup
Class (computer programming) wikipedia , lookup
Monitor (synchronization) wikipedia , lookup
C Sharp syntax wikipedia , lookup
Transcript
Programming Assignment 3 Multithreading A program needs to carry out more than one task at the same time, such as in the case of a web browser downloading a picture while displaying rest of the page. Using more than one thread within a program is called multithreading. Java makes multithreading available to the programmer. The purpose of this assignment is for you to become familiar with threaded programming. You may choose to write any program you wish. Think of an interesting program to do. It does not have to be elaborate. For example, you can write a server that accepts multiple clients. Hint: In Java, an object can run as a thread if it implements the inbuilt interface Runnable, which has just one method: run. Thus, in order to implement the interface, we simply have to provide a definition for method run. Since the inbuilt class Thread implements this interface, there are two fundamental methods for creating a thread class: - create a class that extends Thread; o Example: public class MyThreads extends Thread - create a class that does not extend Thread and specify explicitly that implements Runnable. o Example: Thread thread1 = new Thread(runnable1);