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 7555821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:42:38+00:00 2026-05-30T11:42:38+00:00

I don’t know if this is the best approach so that’s why I’m asking

  • 0

I don’t know if this is the best approach so that’s why I’m asking your help guys.

This is my problem, I’m developing an app where you have the ‘read’ button, when the user hit this button then the program start to read some values and save this values in my database, okay ?

So I think when the user hit ‘read’ I start a thread, that’s because the user can do another thing if he wants without the app been freeze.
But I cannot access the values read by this thread.

There’s another way to do that ?

EDIT:

    private void jtb_readerItemStateChanged(java.awt.event.ItemEvent evt) {                                            
        // getting some values provided by the user       

        if (buttonReaderState()){
            if (supervisory == null)
                supervisory = new Supervisory(ip, broadcast, deviceID);
                supervisory.start();
        }
    }                                           

// Supervisory class
    public void start(){
        Scan scan = new Scan();
        Thread t = new Thread(scan);
        t.start();
        threadState = true;
    }

    class Scan extends Thread{
        public void run(){
            // inside the tread I have to initiate another 'supervisory' object, is that right ? 
            Supervisory s = new Supervisory(ip, broadcast, deviceID);
            while (threadState){
                try {
                    s.active();

                } catch (IOException ioe) {
                    ioe.printStackTrace();

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public void active() throws IOException, Exception  {
        // getting this values from my hardware like temperature and anothers things.

        for (int i = 0; i < ois.size(); i++) {
            ObjectIdentifier oi = ois.get(i);

            //analog input
            if (i == 1)
                aI = Float.parseFloat(getPresentValue(localDevice, oi));
            //analog output
            if (i == 2)
                aO = Float.parseFloat(getPresentValue(localDevice, oi));
            //binary input
            if (i == 3)
                bI = getBinaryValue(getPresentValue(localDevice, oi));
            //binary output
            if (i == 4)
                bO = getBinaryValue(getPresentValue(localDevice, oi));
        }

    }

After reading this values I would like to show this values in the interface that I’m building, but it seems that I cannot have access to these values (aI,aO,bI,bO).

  • 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-30T11:42:40+00:00Added an answer on May 30, 2026 at 11:42 am

    Pass a reference to the interface you have. E.g. you can add a JFrame owner field to Supervisory class and pass your values there.

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

Sidebar

Related Questions

don't know better title for this, but here's my code. I have class user
Don't know if anyone can help me with this or if it's even possible.
Don't know if this is an eclipse specific problem but whenever I declare a
Don't know if this has been answered before. Have custom routes to users. If
I don't have much PHP experience and I want to know how to best
Don't know why but I can't find a solution to this. I have 3
Don't know if there is a better way to do this, so that is
Don't know why but font is not displaying.Please help. CSS(in css folder): style.css: @font-face
I don't know if the correct title for this is hot deploy. I am
(Don't know if this is strictly on-topic, but I don't see any better Stack

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.