• Complain

Badr Benmammar - Concurrent, Real-Time and Distributed Programming in Java: Threads, RTSJ and RMI

Here you can read online Badr Benmammar - Concurrent, Real-Time and Distributed Programming in Java: Threads, RTSJ and RMI full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2018, publisher: ISTE/Wiley, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Badr Benmammar Concurrent, Real-Time and Distributed Programming in Java: Threads, RTSJ and RMI
  • Book:
    Concurrent, Real-Time and Distributed Programming in Java: Threads, RTSJ and RMI
  • Author:
  • Publisher:
    ISTE/Wiley
  • Genre:
  • Year:
    2018
  • Rating:
    4 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 80
    • 1
    • 2
    • 3
    • 4
    • 5

Concurrent, Real-Time and Distributed Programming in Java: Threads, RTSJ and RMI: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Concurrent, Real-Time and Distributed Programming in Java: Threads, RTSJ and RMI" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

This book provides an introduction to concurrent, real-time, distributed programming with Java object-oriented language support as an algorithm description tool. It describes in particular the mechanisms of synchronization (cooperative and competitive) and sharing of data (internal class, static variables) between threads in Java. He then discusses the use of Java for real-time applications. Consequently, a presentation of the RTSJ (Real Time Specification for Java) specification dedicated to the development of real-time applications in Java is also introduced in this book. Finally, a presentation of programming distributed in Java is presented in this book. We are particularly interested in communication using the TCP Sockets and high-level communication using Java Remote Method Invocation (RMI). The book also contains an annex which contains a practical set of application exercises in relation to the theme of the book. Knowledge of the Java language is a prerequisite for understanding the book.

Badr Benmammar: author's other books


Who wrote Concurrent, Real-Time and Distributed Programming in Java: Threads, RTSJ and RMI? Find out the surname, the name of the author of the book and a list of all author's works by series.

Concurrent, Real-Time and Distributed Programming in Java: Threads, RTSJ and RMI — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Concurrent, Real-Time and Distributed Programming in Java: Threads, RTSJ and RMI" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
WILEY END USER LICENSE AGREEMENT

Go to www.wiley.com/go/eula to access Wileys ebook EULA.

List of Acronyms
APIApplication Programming InterfaceCNICygnus Native InterfaceCORBACommon Object Request Broker ArchitectureDCOMDistributed Component Object ModelDGCDistributed Garbage CollectionFIFOFirst In, First OutGCGarbage CollectorGCCGNU Compiler CollectionGCJGNU Compiler for JavaGNUGNUs Not UnixIIOPInternet Inter-ORB ProtocolIPInternet ProtocolJ2SEJava 2 Standard EditionJ2EEJava 2 Enterprise EditionJ2MEJava 2 Micro EditionJDKJava SE Development KitJNIJava Native InterfaceJRMPJava Remote Method ProtocolJSSEJava Secure Socket ExtensionJVMJava Virtual MachineKVMKilo VMOSIOpen Systems InterconnectionPCPPriority Ceiling ProtocolPIPPriority Inheritance ProtocolRMIRemote Method InvocationRMICRMI CompilerRPCRemote Procedure CallRRLRemote Reference LayerRTSJReal-Time Specification for JavaSSLSecure Sockets LayerTCPTransmission Control ProtocolTLSTransport Layer SecurityUDPUser Datagram ProtocolURLUniform Resource LocatorWinCEWindows Embedded Compact
Appendix
Exercise 1: lifecycle of a thread

Consider the following class:

class Parrot4 extends Thread{ private String cri = null; private int fois = 0; public Parrot4 (String s, int i) { cri = s; fois = i;} public void run() { System.out.println("Thread parrot:" + Thread.currentThread().getName()); for (int n=0; nclass ChatAndLaunchParrot4{ public static void main(String args[]) { Parrot4 parrot = new Parrot4("coco",5); parrot.start(); System.out.println("Thread chatty : " + Thread.currentThread().getName()); for (int n=0; n<15; n++) { try { Thread.sleep(1000);} catch(InterruptedException e) { } System.out.print("Thread parrot isAlive: "+ parrot.isAlive()+"\t"); blabla(); } } private static void blabla() { System.out.println("blabla"); }}

Question: Launch the execution of the above program.

What is the name of the primary thread, what is the name given by default to the other thread? What is the point of the isAlive() method? Hint: the class method currentThread() returns a pointer on the object Thread, which calls this method.

Exercise 2: properties of different threads

Consider the following two classes:

class Parrot5 extends Thread { private String cri = null; private int fois = 0; public Parrot5(String s, int i) { super("parrot"); cri = s; fois = i;}public void run(){ afficheThreads(); for (int n=0; n< nbrThread ; i++) System.out.println(i + "-ieme Thread: " + tabThread[i].getName()); }}class ChatAndLaunchParrot5 { public static void main(String args[]) { Thread.currentThread().setName("chatty"); Parrot5 parrot = new Parrot5("coco",15); parrot.start(); for (int n=0; n<5; n++) { try { Thread.sleep(1000); } catch(InterruptedException e) { } blabla(); } } private static void blabla() { System.out.println("blabla"); } }

Hint: The method setName (String name) makes it possible to name a thread. The Thread builder offers the possibility to name it as follows: Thread (String name).

The class method activeCount () gives the number of active threads in the calling threads group.

The class method enumerates (Thread[] table) stores in the given table the references of the active threads in the calling threads group and sub-groups. It returns the number of active threads obtained.

Question: launch the execution of the previous program.

The procedure displayThreads() is called before and after the loop for the method run().

The active threads before the loop were:

Number 0 Thread: chatty

1st Thread: parrot

After the loop for, they became:

Number 0 Thread: parrot

1st Thread: DestroyJavaVM

Explain this result, what is DestroyJavaVM?

Exercise 3: four counters in parallel

The objective for this exercise is to create four counters executing in parallel.

Each "counter" has a name (Toto for example) and it counts from 1 to 10. It pauses randomly between each number (0 to 5000 milliseconds for example). Each counter displays a number (for example, Toto will display, "Toto: 3"); n displays a message such as "Toto has finished counting to 10" when it has finished.

The counter class possesses one single attribute, which is the name of the String-type counter.

Write the counter class and test it by launching 4 that count up to 10. See which one finishes first (the four counters are named Tata, Titi, Toto, Tutu).

Make 2 versions: one where the threads are created with a Thread daughter-class, and one where they are created with an instance of a separate class that implements Runnable.

Exercise 4: resource in mutual exclusion

Consider the following three java classes:

public class Printer1 { private String text; public Printer1() { text="";} public void print(String t) { text=t; for (int j=0;jpublic class Prog56 { public static void main (String argv[]) { Writer2 writerA, writerB; Printer1 print= new Printer1(); writerA = new Writer2("ABC", print); writerB = new Writer2("XYZ", print); writerA.start(); writerB.start(); }}public class Writer2 extends Thread { private String text; private Printer1 print; public Writer2(String t, Printer1 i) { print=i; text=t; } public void run() { for (int i=0; i<10; i++) { print.print(text); try { sleep((long)(Math.random() * 100));} catch (InterruptedException e) {} } // end for System.out.println("writer of " +text+" has finished"); }}
  • In the class Printer1, describe the behavior of the print method.
  • Describe the behavior of a thread of type Writer2 (explain the run() method).
  • Launch the execution of Prog56. Why is the result of the prints illegible?
  • Change in the class Printer1 the signature of the print method to public synchronized void print (String t) and restart the execution of Prog56.
  • What is the point of the synchronized method?
Exercise 5: program a task with an initial delay and a periodicity

We wish to teach a student the multiplication table for 7, and this is why we want to program a task that displays the multiplication table of 7 every 4 seconds and with an initial delay of 2 seconds. The result is obtained in the following form:

Do you still want to learn the multiplication table? (y/n) The multiplication table for 7 is:

1 * 7 = 7

2 * 7 = 14

3 * 7 = 21

4 * 7 = 28

5 * 7 = 35

6 * 7 = 42

7 * 7 = 49

8 * 7 = 56

9 * 7 = 63

10 * 7 = 70

PS: Any answer other than y cancels the programming.

Exercise 6: shared variables: internal class

Consider the two following classes (the class Parrot20 is called internal class because it is located inside the class MathsParrots20), and there is a single java file called MathsParrots20.java.

public class MathsParrots20{ private int counter; public static void main(String args[]) { new MathsParrots20(); } public MathsParrots20() { counter = 1; Parrot20 parrotA = new Parrot20("coco", 10); Parrot20 parrotB = new Parrot20("hello", 10); parrotA.start(); parrotB.start(); try { parrotA.join(); parrotB.join(); } catch(InterruptedException e) { } System.out.println("counter = "+counter); } class Parrot20 extends Thread { private String cri = null; private int fois = 0; public Parrot20(String s, int i) { cry = s; times = i; } public void repeat() { String repeat = cry + " " + counter; System.out.println(repeat); counter++; try { Thread.sleep((int)(Math.random()*1000)); } catch(InterruptedException e) { } } public void run(){ for (int n=0; n
  • Launch and examine the execution.
  • Hint: join() is used in order to display the value of the counter before the end of the two threads. Due to the visibility rules in Java, the counter variable is visible/accessible from the Parrot20 class and therefore for both parrotA and parrotB threads. The two threads therefore access a shared space common to all variables, unlike the processes that possess their own work space separate from other processes.
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Concurrent, Real-Time and Distributed Programming in Java: Threads, RTSJ and RMI»

Look at similar books to Concurrent, Real-Time and Distributed Programming in Java: Threads, RTSJ and RMI. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Concurrent, Real-Time and Distributed Programming in Java: Threads, RTSJ and RMI»

Discussion, reviews of the book Concurrent, Real-Time and Distributed Programming in Java: Threads, RTSJ and RMI and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.