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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:48:31+00:00 2026-06-14T20:48:31+00:00

Why is this program not working? (It doesn’t print Running…) package eu.inmensia.learn; import java.awt.Canvas;

  • 0

Why is this program not working? (It doesn’t print “Running…”)

package eu.inmensia.learn;

import java.awt.Canvas;
import java.awt.Dimension;

import javax.swing.JFrame;

public class Client extends Canvas implements Runnable {

    private static final long serialVersionUID = 1L;
    public static final int WIDTH = 300;
    public static final int HEIGHT = WIDTH / 16 * 9;
    public static final short SCALE = 3;

    private Thread thread;
    private JFrame frame = new JFrame();
    private boolean running = false;

    public Client() {
        Dimension size = new Dimension(WIDTH * SCALE, HEIGHT * SCALE);
        setPreferredSize(size);
    }

    public synchronized void start() {
        running = true;
        thread = new Thread("display");
        thread.start(); // start the thread
    }

    public synchronized void stop() {
        running = false;
        try{
            thread.join(); // end the thread
        }catch(InterruptedException e){ e.printStackTrace(); }
    }

    public void run() {
        while(running){
            System.out.println("Running...");
        }
    }

    public static void main(String[] args) {
        Client client = new Client();
        client.frame.setResizeable(false);
        client.frame.setTitle("Program test");
        client.frame.add(client);
        client.frame.pack();
        client.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        client.frame.setLocationRelativeTo(null);
        client.frame.setVisible(true);

        client.start();
    }
}

I’m trying to learn threads, and it’s one, if not the most hard, thing I ever have learned. OOP is nothing to this xD

  • 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-14T20:48:32+00:00Added an answer on June 14, 2026 at 8:48 pm

    Because of this

    new Thread("display");
    

    Change it to

    new Thread(this)
    

    I just hope you know what you’re doing.

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

Sidebar

Related Questions

when I run this program, it print NameError global name 'viewAll' is not defined
This program returns: package main import ( flag fmt ) func main() { num_agents
For some reason this program is saying that 'switch' is not defined. What is
How can I implement generics in this program so I do not have to
This is not homework, I need this for my program :) I ask this
This is currently what I have to delete the file but it's not working.
I'm running a program using command line in c# this program produce some logs
Somehow this call to free() is not working. I ran this application on Windows
I'm using this Java program to communicate with an Arduino board. However, I'm having
Good day! I encountered the following error upon running my JSP program. java.lang.IllegalStateException: PWC3991:

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.