I have asked this question so many times and have tried so many different things that I don’t know where to turn.
Could someone please write a program for me to show me how to do this and make sure it works with well commented code. If not at least get me a good example. All my efforts are at the bottom of this post, but are not currently working.
Thread 1: GUI / visible .jar program
Thread 2: Random Number Generator
How would you get thread 1 to get updated after thread 2 generates a number? This update would be done every two seconds by Thread 2.
Download my source:
Thread key1 = new Thread(new randomKeyGen(ranLKey));
key1.start();
Thats what I use to get my random class.
Random Class: http://pastebin.com/rTPnYsVX
Here are other posts that did not get me ANYWHERE!!!:
Use a Swing Timer. As long as the Timer has access to the label you can update the text and the Timer executes on the EDT so all you have to do is update the label with your random number.
We are not interested in looking at code on pastebin. Post your code here and keep the code simple. See the link on creating a SSCCE. Your whole demo program should be about 20-30 lines of code. That way its easy to debug and understand.