Java代写 | Java Final Project | Java多线程 | CS代写

Java代写/Java多线程/Java并发编程/Java Synchronized/Thread类/Runnable接口

这门课程是PROGRAMMING LANGUAGES,本次的Final Project是分别用两门语言,Java/erlang模拟多线程并发

due时间约为48小时左右,最后在短短的24小时内完成Java和erlang两个版本的代码编写并测试通过。

DESCRIPTION: For the final project, we will take a look at Erlang. Note that while Erlang is a functional language, in the same style as Clojure, our focus here is the concurrency model provided by Erlang. In particular, this assignment will require you to gain some familiarity with the concept of message passing. In fact, Erlang does this more effectively than any other modern programming language.

That said, there is a “twist” with the project. The course is called “Comparative Programming Languages” for a reason. The purpose is not just to learn something about other languages but to get a better sense of how problems can be solved differently, depending on the language used. Often, a well-chosen language can make the job much easier and much more intuitive.

So, in addition to implementing the application in Erlang, you will implement the same application using Java, arguably the most popular imperative language in use today. While Java will be far more comfortable for many of you, it is a general purpose language that was not designed specifically for concurrency (though it has always provided support for this).

In short, the project emphasizes the “comparative” element in the course’s title. Note, however, that this does not mean that the project is massive in size. The application itself is not large, so neither the Erlang program nor the Java program will require a huge amount of source code. Instead, you will have to look at the problem differently in the two cases.

DETAILS: In the description below, we will describe the project in terms of Erlang. A short section on the Java version will be given at the end.

So your task is to provide an extremely simple communication network for a group of friends. It is so simple that all the friends will actually do is send a contact message to one or more people in the group, and then wait for a confirmation reply from that person. That’s it.

You will, of course, need a list of a group of friends and the contact messages that will be sent by each person. This information will be read from a file called “calls.txt” that will be located in the same folder as the application code. While Erlang provides many file primitives for processing disk files, the process is not quite as simple as Clojure’s slurp() function. So the “calls.txt” file will contain call records that are already pre-formatted. In other words, they are ready to be read directly into Erlang data structures. An example of a “calls.txt” file is:

{john, [jill,joe,bob]}.
{jill, [bob,joe,bob]}.
{sue, [jill,jill,jill,bob,jill]}.
{bob, [john]}.
{joe, [sue]}.

Here, we have five “calling” tuples. The first field in each tuple contains the name of the person who will make the calls. The second field is a list of friends that this person will contact. So, for example, the first tuple indicates that john will contact jill, joe, and bob.

To read this file, all you simply have to use is the consult() function in the file module. This will load the contents into an Erlang list of 5 tuples (in this particular case). Note that NO error checking is required. The “calls.txt” file is guaranteed to exist and contain valid data. Each person will make at least one contact with another person, and all people in the contact list are guaranteed to exist and make at least one call.

To confirm the validity of the program, each person receiving a contact request – either an initial request or a response – must send a message to the master process to inform it about the exchange.

IMPORTANT: The “master” process is the only process that should display anything to the screen. No “person process” should directly display anything, other than termination messages.

Below, we see sample output for our “calls.txt” example:

** Calls to be made **
john: [jill,joe,bob]
jill: [bob,joe,bob]
sue: [jill,jill,jill,bob,jill]
bob: [john]
joe: [sue]
bob received intro message from jill [738000]
joe received intro message from john [741004]
bob received intro message from john [770008]
joe received intro message from jill [779007]
john received intro message from bob [736102]
john received reply message from joe [741004]
jill received intro message from sue [737001]
bob received intro message from jill [816004]
bob received reply message from john [736102]
bob received intro message from sue [897005]
jill received intro message from john [739000]
jill received reply message from bob [738000]
john received reply message from jill [739000]
jill received intro message from sue [819004]
jill received reply message from joe [779007]
jill received intro message from sue [880460]
jill received reply message from bob [816004]
sue received intro message from joe [828004]
sue received reply message from jill [737001]
sue received reply message from bob [897005]
sue received reply message from jill [819004]
sue received reply message from jill [880460]
joe received reply message from sue [828004]
jill received intro message from sue [987009]
sue received reply message from jill [987009]

The Java version can have multiple source files, depending on how you choose to organize your code. However, the main “driver” class must be called exchange.java. It will have the main method and will be the entry point for running and testing your code.


程序代写代做C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: [email protected]  微信:dmxyzl003 工作时间:全年无休-早上8点到凌晨3点


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。

发表评论