lab6/src/main/java/com/mycompany/lab6/Producer.java
/**
     * thread method used to create a character and add it to the buffer
     */
thread method used to create a character and add it to the buffer
thread method used to create a character and add it to the buffer
@Override
    public void run() {
        Random r = new Random();
        try {
            for (int i = 0; i < Main.bufferSize; i++) {
            spaces.acquire();
            mutex.acquire();
            char temp = (char)(r.nextInt(26) + 'a');
            System.out.println(temp);
            buffer.add(temp);
            mutex.release();
            items.release();
        }
        } catch (Exception e) {
            System.out.println(e.getLocalizedMessage());
        }
    }
@ Override public void run ( ) { Random r = new Random ( ) ; try { for ( int i = 0 ; i < Main . bufferSize ; i ++ ) { spaces . acquire ( ) ; mutex . acquire ( ) ; char temp = ( char ) ( r . nextInt ( 26 ) + 'a' ) ; System . out . println ( temp ) ; buffer . add ( temp ) ; mutex . release ( ) ; items . release ( ) ; } } catch ( Exception e ) { System . out . println ( e . getLocalizedMessage ( ) ) ; } }
thread method used to create a character and add it to the buffer
thread method used to create a character and add it to the buffer