⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hilo.java

📁 solution to the simulation of the vasculating buffer
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package examen;import java.util.Random;/** * * @author ANGEL */public class hilo implements Runnable{    Thread t;    Random r;    int cuantos;    String datos[];    int id;    boolean operacion;    buffer referencia;    hilo(buffer obj,int id,boolean func){        r = new Random();        if(func)            cuantos = 1+r.nextInt(3)+r.nextInt(3);        else            cuantos = 1+r.nextInt(3);        operacion = func;        String funcion;        if(operacion) funcion = "escribira";        else funcion = "leera";        //System.out.println("HILO"+id+" "+funcion +" "+datos+" valores ");        referencia = obj;        this.id = id;        datos = new String[cuantos];        for(int i =0;i<cuantos;i++){            datos[i] = ""+id+"";        }        t = new Thread(this);        t.start();    }    synchronized  public void run(){        int i;        int valor;        if(operacion){            //escribirç                referencia.meter_buffer(datos, cuantos, id);                referencia.recorrercolas();//                    referencia.buscar_escritor().recorrer();        }else{            //leer            referencia.sacar_buffer(cuantos,id); //           referencia.valvula();        }    }    boolean invertir_bool(boolean valor){        return !valor;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -