Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6567735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:22:21+00:00 2026-05-25T14:22:21+00:00

How can i get/set the goal value? So that i can also use it

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:22:21+00:00Added an answer on May 25, 2026 at 2:22 pm

    Define a Callback interface with a complete method that takes any object as an argument

    In the Thread (or Runnable) class pass in the reference to the class that started the thread. When the operation on the thread completes, call the callback method

    Java executors: how to be notified, without blocking, when a task completes?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get Environnment variables and if something is missing, set the value?
Given this variable in tcsh: set i = ~/foo/bar.c how can I get just
I've got a base class from an outside library that I can't modify -
How can I get and set the 'read-only' property of an edit box?
I've set up a very simple example with LINQ-TO-SQL in WPF. I can get
I have a set containing thousands of addresses. If I can get the longitude
can you get the last or newly added element in std::set? for example say
When we define a property like public string Name {get; set;} dot net can
If I have a property: public list<String> names { get; set; } How can
Can get all triples with value null in specific field? All people with date_of_birth

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.