ThreadNotes - Notes On Multithreading in Java Overview...

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

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

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

View Full Document Right 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
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
Image of page 3

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern