0

I am making a program in which the program assigns a variable to the numbers 1 - 10. I am suppose to use wait and notify. I put them in but I don't know how to assign the variables to the numbers. My code is and could someone tell me how would I assign the vairables

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vairables;

public class Vairables {

    public static void main(String[] args) 
    {
        class IntegerHolder
        {
            String variable = null;
            synchronized void insert(String v)
            {
                while (variable != null)
                {
                    
                    notify();
                    
                    wait();
                }
                variable = v;
                notify();
            }
            
            synchronized int extract()
            {
                while ( variable == null)
                {
                    notify();
                    
                    wait();
                }
                String temp = variable;
                variable = null;
                notify();
                return temp;
            }
        }
    }
}
2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by NormR1
0

how to assign the variables to the numbers

What variables?
Normally you assign values to variables. Can you explain what you mean?

Can you explain what you want this code to do?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.