ThreadNotes

ThreadNotes - Notes On Multithreading in Java Overview...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Notes On Multithreading in Java
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Overview Following is a list of topics about multithreading. The list is meant as a reminder to me when I am talking about threads, and as reminders for you when you are reviewing thread concepts in preparation for an exam or a coding project. A comprehensive explanation of the concepts is not included here. That will be done in class and in the lab instructions and in textbooks. When does multithreading come up? Making an object does NOT provide a thread to "run" it ! We may want multiple programs in the JVM to run "concurrently". The O/S (e.g.Windows) "suspends" and "dispatches" threads (giving each thread a "time-slice") to control sharing of the computer hardware. (Only 1 thread is running at any one time in the whole computer!!!) Sometimes a thread goes into a blocked state (a wait state) e.g. when waiting for a message to arrive on a communications line. Sometimes a thread enters wait queues associated with an object. (The JVM controls this.) Every object doesn't need a thread! Objects that represent "things" like queues and Strings and Cars don't need a thead. Such objects are called "Java beans". (They have class names that are nouns .) Their methods are executed by application program threads that call them. (The Car object would be used by an application program like TakeATrip that would have a thread and call the Car's methods to drive it around.) Getting an "application thread" to "run" a program
Background image of page 2
An "application program" - the other kind of class/object: you're either a "bean" or an application! - "runs" procedures (called methods in Java) to get a process done, like Billing or OrderEntry or InventoryUpdate or AccountsReceivable. (These classes have names that are verbs .) We can get a thread for an application program in one of three ways: 1. Have a main() method and start the program from the command line. (Common practice in a course about Java, but rare in "production" programs!) Even this may not provide the threads needed! In Homework3, StartMessageSystem has a main thread, and uses it to load the objects that interact in the lab: the message sender and receiver applications and the message queue. But these classes/objects "by default" do not have a thread. (And MessageQueue, a Java bean, does not want a
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

ThreadNotes - Notes On Multithreading in Java Overview...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online