• Keine Ergebnisse gefunden

Exercise3ThermoControlSystemUsingSynchronousMessages Exercise2JCoBox-Chatsystem Exercise1Asynchronousvs.synchronousCalls PracticeSheet11(HintsandComments) AdvancedAspectsofObject-OrientedProgramming(SS2013)

N/A
N/A
Protected

Academic year: 2022

Aktie "Exercise3ThermoControlSystemUsingSynchronousMessages Exercise2JCoBox-Chatsystem Exercise1Asynchronousvs.synchronousCalls PracticeSheet11(HintsandComments) AdvancedAspectsofObject-OrientedProgramming(SS2013)"

Copied!
1
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Prof. Dr. A. Poetzsch-Heffter Mathias Weber, M.Sc.

University of Kaiserslautern Department of Computer Science Software Technology Group

Advanced Aspects of Object-Oriented Programming (SS 2013) Practice Sheet 11 (Hints and Comments)

Exercise 1 Asynchronous vs. synchronous Calls

a) Synchronous calls: all methods are executed in the order they appear in the snippet. Output:

i=5 i=9

Asynchronous calls: it is unknown, when the methods are executed:

i=5 i=9

or, if C handles the message send by B before the one of A

i=9 i=5

b) With synchronous communication methods are executed completely before the control returns to the caller. That means that the order of execution of methods corresponds to the order of the send messages. In asynchronous contexts, the order of messages may change. Depending on the language, certain guarantees about the message order can be given, but in most cases the order will not be total but some partial order. E.g. in JCoBox it is guaranteed, that if an object a of CoBox a sends two messages to objects in another CoBox, these messages will be handled in the same order as they have been send, but the system makes no guarantees about messages send to or by other CoBoxes.

In multi-threaded contexts the usage of synchronous communication is easier because the behaviour is “easier” to predict. But synchronous communication is a source for deadlocks, which are less likely in asynchronous settings, but for the price of even less predictable behaviour.

Exercise 2 JCoBox-Chatsystem

See provided sources. Note, that no explicit synchronization is needed, in contrast to the multi-thread version of Exercise 10.

Exercise 3 ThermoControl System Using Synchronous Messages

See provided source.

Referenzen

ÄHNLICHE DOKUMENTE

a) Implement a method IPlugin load(String clazz) that loads the plugin with the given name. Please also check that the loaded class really implements the needed interface.. b)

C was declared final, so there cannot be any subclasses of C and m was declared protected, therefore the only code that can call m is inside p, the change of the parameter type is

Does the print method in class PhDAssistant override the print method in class Person ? Hint: look at the Java Language Specification in Section 8.4.8... Exercise

Collection<E> c = ... Write a generic class TransformingIterator and the accompanying interface Transformer , that decorates an existing Iterator with a transformation

a) Model fields form a model state, which can be different from the implemented state.. The model state may be better suited for specifying the behavior of an object, because it can

Since the example program neither uses synchronized blocks nor volatile fields, the value the main threads sets is never synchronized with the background thread. The example can

But now multiple thread can be concurrently in the Map implementation, in order to guar- antee mutual exclusive access for a thread, we have to protect all possible concurrent

a) Write a server that handles multiple clients and accepts new clients at any time. All messages send by any client shall immediately be displayed at all clients. Prefix messages