Menu

(Solved) : Java Write Application Defines Array N Threads Communicate Following Thread Represents Num Q37157327 . . .

(java) write an application that defines an array of n threadsthat communicate with each other as following:

each thread represents a number between 1,..,100(includingboth), and the number is randomly initialized.

the threads will work as following:

every thread checks what is the number inside of its neighboursin the left and in the right(i.e in i-1 and i+1 cells) and actsaccording to the following rules:

a)if the number is smaller than its two neighbours(i-1,i+1) it willincrease its value by one.
b)if the number is larger than its two neighbours, it will decreaseits number by one
c)if its number is between its two neighbours or equal to one ortwo of them, it will leave its number without a change.

the array will work as a circular array, meaning the first threadand the last are considered to be neighbours.
each proccess must not change its number between its neighboursfinished checking it.
the program will perform m rounds of tests.
the number of threads n and the number of rounds m will be recievedas an input from the user.

the output should be represented in a text field with threelines:

1)first line will represent the starting state of thearray
2)second line will represent the numbers in all of the array aftereach thread performed one check.
3)the third line should represent the number in all of the arrayafter each thread made an additional check.

would really appreciate your help with it, stuck on it fordays.

Expert Answer


Answer to (java) write an application that defines an array of n threads that communicate with each other as following: each threa…

OR