• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Converting to run on Concurrent platform

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am looking to try and see if I can get a concurrent program running as I never have done so before and I am currently in a place with 10 computers on a network to try a program out on. So could someone convert this program that I have been working on(below) to be run concurrently using multithreaded java or show me another concurrent program so I can test out whether it works here, so I can start writing some myself.
Thanks
-----------------------------------------------------------------------------
import java.io.*;
class PrintMatrix
{
public static void main(String[ ] args)
{
PrintMatrix theApp = new PrintMatrix();
theApp.run();
}
private void run()
{
int[][] b = new int[5][5];
int[] sum = new int[5];
int total = 0;
//Get the info
for(int i = 0; i < b.length; i++ )
{
System.out.println("Enter data for Column " + (i+1));
for (int j = 0; j < b[i].length; j++ )
{
sum[i] += b[i][j] = getInt();
}
total += sum[i];
}
//Print the info
for(int i = 0; i < b.length; i++ )
{
for (int j = 0; j < b[i].length; j++ )
{
System.out.print(b[j][i] + "\t");
}
System.out.println();
}
//Print the sums
for(int i = 0; i < sum.length; i++){
System.out.print(sum[i] + "\t");
}
System.out.println("Total: " + total);
}
private int getInt()
{
int num;
String inStr = null;
try
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter integer data: ");
inStr = in.readLine();
}
catch(IOException ioe)
{
System.out.println(ioe);
}
num = Integer.parseInt(inStr);
return num;
}
}
[ January 08, 2004: Message edited by: David Hunt ]
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to be clear, are you trying to figure out writing a multi-threaded application to be run concurrently across different networked machines, such that if three threads exist in the Java app, thread 1 would run on computer A, thread 2 would run on computer B, and thread 3 would run on computer C?
Or are you trying to figure out doing something significantly simpler - to write a multi-threaded Java app that runs on a single machine, and communicates with another application across a network, which may well be a running instance of the same multi-threaded Java app?
[ January 09, 2004: Message edited by: Dirk Schreckmann ]
 
David Hunt
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm tring to do a multi threaded program suitable to run on two or more CPU's -so the first one.
The type of thing that helps share the load over a network(although the program I am using isn't anything heavy for the processor, this is just to test that it works.
 
David Hunt
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Has anyone got any idea how to go about this or websites to show me as I do not know where to start.
Thanks.
 
Tongue wrestling. It's not what you think. And here, take this tiny ad. You'll need it.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic