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

  • Home
  • SEARCH
  • 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 8939573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:51:06+00:00 2026-06-15T10:51:06+00:00

I may be really stupid here, but essentially I have a buffer and a

  • 0

I may be really stupid here, but essentially I have a buffer and a thread.

I’ve made the buffer to get a bunch of messages from the user, and I want to create a thread to constantly loop to get the messages from the buffer.

This sound super simple but for some reason it just isn’t working.

Both the buffer and the thread are normal Java classes (not main); Buffer and DisplayThread.

I just can’t seem to get my head around how they’re supposed to work together.

Is this right? Or am I missing something?

public class DisplayThread extends Thread{

    DisplayThread Thread = new DisplayThread(Buffer);
    Thread.start();
    public void run(){
             while(true){
            //will do something          

     }
  }

}

I’ve tried creating a buffer object in the main class, and then passing that in, but it still doesn’t work.

What am I missing?! It must be so obvious but I just can’t see it at all.

  • 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-06-15T10:51:07+00:00Added an answer on June 15, 2026 at 10:51 am

    You’ve got the basic idea, but I’m not sure why you put the new DisplayThread(Buffer) and Thread.start() stuff in the body of the class. Basically, those lines should be called from a method. Lets say, for example, they’re supposed to be called from Main, you’d do something like this:

    public static void main(String[] args){
        Buffer buffer = new Buffer();
        DisplayThread displayThread = new DisplayThread(buffer);
        displayThread.start();
    }
    

    In this scenario, you’re creating the buffer object, and passing it to the DisplayThread. In your display thread, you would create an instance variable of a Buffer, and a constructor to set it, like so:

    public class DisplayThread{
        Buffer buffer;
        public DisplayThread(Buffer buffer){
            this.buffer = buffer;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question may appear really stupid for some of you but i have to
So, this may be a really stupid question, but I'm obviously missing something here.
This may sound really stupid but I have to ask cause I'm not finding
I may be being really stupid here, but my brain's gone blank. I've got
I may be doing something really stupid, but I don't get why the below
I know this may be a stupid question to ask but I have really
This may sound really stupid. but I've got a strange problem with the D
Now, this may be really stupid. But can we deploy a Java Swing Application
This question may have been asked before, but I'm starting to get into game
This question may be a stupid question, but I'm really curious. After playing games

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.