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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:55:04+00:00 2026-05-18T22:55:04+00:00

I have an abstract class as follows: abstract class Grapher implements Runnable{ … member

  • 0

I have an abstract class as follows:

abstract class Grapher implements Runnable{
  ... member variables...
  Timer timer;
  boolean Done;

   public void run(){
          Done = false;
          timer.start();
          while(!Done){}
   }

   public void Grapher(){ //create graph}
   ...
   }

The idea is that I want to have this abstract thread that creates a graph. I then want to extend this class to provide the implementation of what data that should be plotted on the graph. For example:

class RandomGraph extends Grapher{
   ActionListener taskPerformer;

   public RandomGraph(){
      timer = new Timer(1000, taskPerformer);
        taskPerformer = new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
               // generate random data and add it to the graph data;
               // if ... Done = true
             }

         };
  }}

This should then plot random data to the graph. The problem I’m having is that I’m getting completely stuck in the while(!done) loop. Putting System.out.printlns inside the actionListener tell me the timer does not seem to be working as nothing appears on the console.

Am I being stupid for using threads at all? I thought it might be a good idea If I want the graph to plot data every few milliseconds.

  • 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-18T22:55:04+00:00Added an answer on May 18, 2026 at 10:55 pm

    You’re passing null to the Timer constructor — you need to initialize taskPerformer first 🙂

    To address your bigger question: No, you’re not stupid for using threads. However, I question your use of an abstract class at all here. What you really want is an interface Grapher describing an object that draws graphs, then a concrete subclass of Runnable (say, GrapherRunner) that sets up the timer, then delegates to a grapher to do the work.

    (In OO-speak, this means using composition rather than inheritance.)

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

Sidebar

Related Questions

I have an abstract class that implements IDisposable, like so: public abstract class ConnectionAccessor
I have an abstract class that looks as follows. public abstract class Entity<PK extends
If you have a base class defined as follows: public abstract class BaseMessageObject<T> where
My entities are as follows: @Entity @Table(name=`surveys`) @Inheritance @DiscriminatorColumn(name=`type`) public abstract class Survey implements
I have a simple hierarchy like follows: public abstract class AbsFoo { protected AbsBoo
Suppose we have abstract class A (all examples in C#) public abstract class A
I have abstract BaseController, which basically looks like below: public abstract class BaseController :
I have a interface as follows public interface IX { void MethodA(); void MethodB();
I have an abstract class defined as follows: abstract class Abstract Parent extends Zend_Db_Table_Abstract
Let's say I have three classes set up as follows: abstract Class A {

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.