{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

java-threads-tutorial

java-threads-tutorial - Introduction to Java threads...

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

View Full Document Right Arrow Icon
Introduction to Java threads Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Table of Contents If you're viewing this document online, you can click any of the topics below to link directly to that section. 1. About this tutorial ....................................................... 2 2. Thread basics ........................................................... 3 3. A thread's life ............................................................ 8 4. Threads everywhere ................................................... 13 5. Sharing access to data ................................................ 16 6. Synchronization details ................................................ 22 7. Additional thread API details ......................................... 26 8. Wrapup and resources ................................................ 28 Introduction to Java threads Page 1 of 30
Image of page 1

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

View Full Document Right Arrow Icon
Section 1. About this tutorial What is this tutorial about? This tutorial explores the basics of threads -- what they are, why they are useful, and how to get started writing simple programs that use them. We will also explore the basic building blocks of more sophisticated threading applications -- how to exchange data between threads, how to control threads, and how threads can communicate with each other. Should I take this tutorial? This tutorial is for Java programmers who have a good working knowledge of the Java language, but who have limited experience with multithreading or concurrency. At the completion of this tutorial, you should be able to write simple programs that use threads. You should also be able to read and understand programs that use threads in straightforward ways. About the author Brian Goetz is a regular columnist on the developerWorks Java technology zone and has been a professional software developer for the past 15 years. He is a Principal Consultant at Quiotix , a software development and consulting firm located in Los Altos, California. See Brian's published and upcoming articles in popular industry publications. Contact Brian at [email protected] . ibm.com/developerWorks Presented by developerWorks, your source for great tutorials Page 2 of 30 Introduction to Java threads
Image of page 2
Section 2. Thread basics What are threads? Nearly every operating system supports the concept of processes -- independently running programs that are isolated from each other to some degree. Threading is a facility to allow multiple activities to coexist within a single process. Most modern operating systems support threads, and the concept of threads has been around in various forms for many years. Java is the first mainstream programming language to explicitly include threading within the language itself, rather than treating threading as a facility of the underlying operating system. Threads are sometimes referred to as lightweight processes . Like processes, threads are independent, concurrent paths of execution through a program, and each thread has its own stack, its own program counter, and its own local variables. However, threads within a process are less insulated from each other than separate processes are. They share memory, file handles, and other per-process state.
Image of page 3

Info icon This 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