Академический Документы
Профессиональный Документы
Культура Документы
java que
es la que lee un archivo.
import java.io.*;
int charInt=-1;
try{
charInt=System.in.read();
System.out.println(e.getMessage());
System.exit(0);
return (char)charInt;
char nextChar;
String result="";
boolean valor=false;
while(!valor){
nextChar=car();
if(nextChar=='\n')
valor=true;
else if(nextChar=='\r'){}
else
result+=nextChar;
}
try{
return Integer.parseInt(result);
catch(NumberFormatException e){
return 0;
char nextChar;
String result="";
boolean done=false;
while(!done){
nextChar=car();
if (nextChar=='\n')
done=true;
else if(nextChar=='\r'){}
else
result+=nextChar;
return result;
while(cont==n)
try
wait();
}catch(InterruptedException e)
System.out.println("Error: "+e.toString());
buffer[cont]=v;
cont++;
if(cont==1)
notify();
}
public synchronized void Sacar()
int valor;
while(cont==0)
try
wait();
}catch(InterruptedException e)
System.out.println("Error: "+e.toString());
cont--;
valor=buffer[cont];
if(cont==n-1)
notify();
}
class Productor extends MyObject2 implements Runnable{
this.almacen=almacen;
int num;
while(true)
num=((int)(Math.random()*200));
almacen.Poner(num);
nap(200);
this.almacen=almacen;
while(true)
almacen.Sacar();
nap(400);
int runTime=60,n;
System.out.println("\n\t\t\t*******Productor-
Consumidor*******");
Hilo_Produce.start();
Hilo_Consume.start();
Hilo_Produce.stop();
Hilo_Consume.stop();
System.exit(0);
}
Clase MyObject
import java.io.Serializable;
import java.util.Date;
import java.util.Random;
super();
this.name = name;
return Thread.currentThread().getName();
try{
Thread.sleep(napTimeMs);
return rnd.nextDouble();
return rnd.nextDouble()*ub;