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;
            }
        }
    }
}

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.