• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

JAVA-Synchronization -VERY beginner-Help

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, my knowledge of java language isnt great, so would appricviete it if any of you could help me out with this problem .

im trying to propose an application java multi process (threads) implementing the algorithm of the calculation of the "standard line" of a matrix A and B. This standard line called Z and its defined by : z=�UC�U or C=A*B;
A=(a ik)//ik are the indices of matrix A. B = (B kj)// kj are the indices of the matrix B. C = (C ij)// ij are the indices of the matrix C.
ij = ��a (ik) * B (kj)// K of 1 A p.
D (i) = ����C (ij) �� J of 1 A m.
Z = max (D (I))// I of 1 A N.
N, m, p, A, B should be read

I have been given this methode that im trying to use , but i am still not sure how to impliment it ( so, will need help with that):

steps are:
To calculate "Z" of a matrix C how its:
1- C is calculated from the product of A and B
2- make the sum of each line of the matrix C and put it in tables named D.
3- from there take the maximum of this table and the max of D it is standard Z of the matrix

B the indication to be added in relation to the java language

1 in the program will use 3 threads that we call: T1, T2, T3.
** the first thread T1 will carry out the product of both matrix A and B.
** the second thread T2 makes the sum of the lines of the matrix C.
** the third thread T3 will do the maximum of tables D.

2 if the matrix C result of product A and B has a dimension of (n*m) and for precise parallelism we will make of the first thread (n*m) other thread each will deal with the product of only one element of the matrix C.

i.e. if have a matrix C of (4*4) we will have 16 threads created of the first thread T1, the 16 thrads each will make the product of only one element of the matrix C.

3-Entering matrix A and B will not be done using the interface in javas but its the console which will deal with entering them
i.e. it is the computer which gives the values of the two matrices in a random way by using the methods randome
"for(int I = 0; I < N; i++ for(int J = 0; J < m; j++)

A [j ] = Math.random(); initialization of matrix A.
for(int I = 0; I < N; i++)
For(int j=0;j

B [j ] = Math.random(); initialization of the matrix B "and the dimensions used will be " int N = A.length; "for the lines and int m = A[0].length;for the columns.

we enter them and use for example "system.in.readln(n)" and "system.in.readln(m)".

4- after having implemented the methods run() and start() of the three thread we add the key word (synchroniserd) for the 3 threads since thread T2 cannot work except if it has the elements from the first thread T1 and similarly for the third thread T3.

NOTES:
- do not use the method stop() for the 3 threads notices
- matriecs A and B are created and of same dimension.(n*m) .
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Chazz.
While we love to discuss all things Java, it's pretty clear that you are working on a homework assignment. Since the only way to learn to write code is to write code, we're going to ask you to do your own work. If you have specific questions, like a compile error you can't solve or how synchronization works between threads for example, we'd be glad to help.
 
chazz lee
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply , i already said in the begining of my question that im a VERY beginer in java , and i know im working on an assignment, which i tryed all my best to solve and couldnt, and thats why i was asking for help.
thanks for answearing anyways.
 
If you send is by car it's a shipment, but if by ship it's cargo. This tiny ad told me:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic