1 / 20

Distributed Systems

Distributed Systems. Agenda. The Java Language Threads I Threads in Java. Procedural versus Object-oriented Programming. In building network applications, there are two main classes of programming languages: procedural language and object-oriented language .

fidelio
Télécharger la présentation

Distributed Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Distributed Systems

  2. Agenda The Java Language • Threads I • Threads in Java

  3. Procedural versus Object-oriented Programming In building network applications, there are two main classes of programming languages: procedural language and object-oriented language. • Procedural languages, with the C language being the primary example, use procedures (functions) to break down the complexity of the tasks that an application entails.  

  4. Procedural versus Object-oriented Programming • Object-oriented languages, exemplified by Java, use objects to encapsulate the details. Each object simulates an object in real life, carrying state data as well as behaviors. State data are represented as instance data. Behaviors are represented as methods.

  5. UML Class Diagram Notations

  6. UML Class Diagram Notations

  7. UML Class Diagram Notations

  8. The Architecture of Distributed Applications

  9. Operating Systems Basics

  10. Operating systems basics • A process consists of an executing program, its current values, state information, and the resources used by the operating system to manage its execution. • A program is an artifact constructed by a software developer; a process is a dynamic entity which exists only when a program is run.

  11. Process State Transition Diagram

  12. Java processes • There are three types of Java program: applications, applets, and servlets, all are written as a class. • A Java application program has a main method, and is run as an independent(standalone) process. • An applet does not have a main method, and is run using a browser or the appletviewer. • A servlet does not have a main method, and is run in the context of a web server. • A Java program is compiled into bytecode, a universal object code. When run, the bytecode is interpreted by the Java Virtual Machine (JVM).

  13. Three Types of Java programs • Applications a program whose byte code can be run on any system which has a Java Virtual Machine. An application may be standalone (monolithic) or distributed (if it interacts with another process). • Applets A program whose byte code is downloaded from a remote machine and is run in the browser’s Java Virtual Machine. • Servlets A program whose byte code resides on a remote machine and is run at the request of an HTTP client (a browser).

  14. Three Types of Java programs

  15. Concurrent Processing On modern day operating systems, multiple processes appear to be executing concurrently on a machine by timesharing resources.

  16. Concurrent processing within a process It is often useful for a process to have parallel threads of execution, each of which timeshare the system resources in much the same way as concurrent processes.

  17. What are Threads? • A thread is a task • A thread task can run in parallel with other threads • Java already implements threads, for example: • Garbage collection occurs in the background • GUIs gather user events in the background • It is also possible for applications to implement threads

  18. What are Threads? (Cont) • A Thread also seems to have it’s own CPU, memory and registers, but share their variables. • Each Thread represents a separate flow of logic through the program (it has it’s own Runtime stack, etc.) • Threads are often referred to as Light Weight Process (LWP), and Processes are referred to as Heavy Weight Processes (HWP)

  19. What are Threads? (Cont) • Modern Operating Systems also support Threading. • Threading is more efficient than separate processes. • Example of Threading in a Web Browser • Separate Threads downloads each image • One Thread displays HTML • Another Thread handles user input • Makes Browser seem more responsive.

  20. Threads • The JVM itself is multithreaded – one thread runs the program while the garbage collector runs on a separate Thread. • GUI programs also spawn a new Thread when the container is shown. This is why closing the window doesn’t close the program.

More Related