Skip to main content

2020 | OriginalPaper | Buchkapitel

16. Multithreading

verfasst von : David Parsons

Erschienen in: Foundational Java

Verlag: Springer International Publishing

Aktivieren Sie unsere intelligente Suche, um passende Fachinhalte oder Patente zu finden.

search-config
loading …

Abstract

This chapter looks at threads, using both inheritance from the Thread class, and implementing the Runnable interface. It outlines the various states that a thread can be in during its lifetime (ready, running, non-runnable, and dead). Code examples illustrate how multiple threads can be run concurrently, and how they can be put to sleep for certain periods of time. It explains how different priorities can be assigned to separate threads, and how these threads can be made less selfish by asking them to yield to other threads. Syntax differences between inheriting from the Thread class and implementing the Runnable interface are explained. A code example of applying the Runnable interface uses graphical objects to visualize how multiple threads can operate concurrently within an inheritance hierarchy. The chapter also explains how the Object class provides some methods; “wait”, “notify”, and “notifyAll”, which enable threads to avoid concurrent access to certain parts of code, known as “monitors”, that are marked by the “synchronized” keyword. The chapter concludes with a brief introduction to the concurrent collections in the “java.util.concurrent” package.

Sie haben noch keine Lizenz? Dann Informieren Sie sich jetzt über unsere Produkte:

Springer Professional "Wirtschaft+Technik"

Online-Abonnement

Mit Springer Professional "Wirtschaft+Technik" erhalten Sie Zugriff auf:

  • über 102.000 Bücher
  • über 537 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Maschinenbau + Werkstoffe
  • Versicherung + Risiko

Jetzt Wissensvorsprung sichern!

Springer Professional "Technik"

Online-Abonnement

Mit Springer Professional "Technik" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 390 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Maschinenbau + Werkstoffe




 

Jetzt Wissensvorsprung sichern!

Springer Professional "Wirtschaft"

Online-Abonnement

Mit Springer Professional "Wirtschaft" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 340 Zeitschriften

aus folgenden Fachgebieten:

  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Versicherung + Risiko




Jetzt Wissensvorsprung sichern!

Metadaten
Titel
Multithreading
verfasst von
David Parsons
Copyright-Jahr
2020
DOI
https://doi.org/10.1007/978-3-030-54518-5_16

Premium Partner