I have variables that i want to share between threads but they are giving me some problems! I have an Integer that i want the main program to share with the threads it is creating and allow the threads to change its value and being seen by the other threads and the main program (I hace two different types of threads and I want to create more than one of each). I have already consider the critical section. This is a part of my program:
public static void main(String[] args) throws InterruptedException{
Integer t = 0; //What do I change here?
(new Te(t)).start();
(new In(t)).start();
}
I haven't written all my program but in this case the interested variable is t, that is going to be changed by Threads and its new valuable must be seen by the main program in case it creates a new Thread and by the threads when they want to read/write .
If it isnt clear with just these, I can post more code if it is needed!
Thank you very much in advance :)