Commit 5dcff7ab authored by Matti Pulkkinen's avatar Matti Pulkkinen
Browse files

Merge branch 'master' into 'master'

Master

See merge request mkjpul/DTEK1066-ryhmis!2
parents 88b41fc4 2d686d37
//Testi
package fi.utu.dtek1066;
import java.io.IOException;
......
//class public Summatallennus{
public static class Summainlanka extends Thread {
//private final Semaphore vapaa = new Semaphore(1);
private Socket[] lankasocket= new Socket[lanka];
private ObjectInputStream[] numerot = new ObjectInputStream[lanka];
private static ArrayList<Integer>[] pankki = new ArrayList[lanka];
//
static public int getSumma(){
int summa = 0;
for(int i=0; i<lanka; i++){
for(int j=0; j<pankki[i].size(); j++){
summa = summa + pankki[i].get(j);
}
}
return summa;
}
static public int getKoko(){
int koko=0;
for(int i=0; i<lanka; i++){
koko = koko + pankki[i].size();
}
return koko;
}
static public int getSuurin(){
int arvo=0;
int suurin=0;
int summa=0;
for(int i=0; i<lanka; i++){
for(int j=0; j<pankki[i].size(); j++){
summa = summa + pankki[i].get(j);
}
if(summa>suurin){
arvo=i+1;
summa=suurin;
}
}
return arvo;
}
public void run(){
for(int i=0; i<lanka; i++){
int porttinumero = ;
try{
System.out.println("Avaa portin: " + porttinumero);
ServerSocket lankaserveri = new ServerSocket(porttinumero);
lankasocket[i]=lankaserveri.accept();
numerot[i] = new ObjectInputStream(lankasocket[i].getInputStream());
pankki[i] = new ArrayList<Integer>();
lankaserveri.close();
//synchronized (portti){}
}
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment