How can i get/set the "goal" value?
- So that i can also use it from other class or threads? I tried this but its always giving null or nothing instead of showing me "5" goals.
Main.java:
public class Main
{
public static String goal = null;
public static void main(String[] args)
{
System.out.println(goal); // shows: null
MyFunction1();
System.out.println(goal); // How many goals happend till now?
}
public static void MyFunction1()
{
new Thread(new Runnable()
{
public void run()
{
CallMe();
System.out.println("show me: " + goal); // shows nothing.
}
}).start();
}
public static void CallMe()
{
ThirdpartySoftware.Bla().connect(new Bla.STATE()
{
public void stateChanged()
{
System.out.println("Am i running? yes");
goal = "5";
System.out.println("Did i assigned new value to goal? yes");
}
});
}
}
Note: I am now separately trying, to fire a event > new thread as abstract interface > implement that interface as a thread and from that thread assign the variable to main class static variable. And then listen on a virtual threads. So in total i may have: Main > Thread1 > ThirdpartyThred > Abstract interface > Thread2 > Main put/get