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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:56:24+00:00 2026-05-27T20:56:24+00:00

im making a server for an application, and I made a thread for accepting

  • 0

im making a server for an application, and I made a thread for accepting user’s.

but it seems that it doesn’t come to my overrided method run()

it doesn’t give me an error or such it just doesn’t run.

Here is the code:

This is the Client listener

package org.walking.server.listener;

import java.io.IOException;
import java.net.ServerSocket;

import javax.swing.SwingWorker;
/*
 * Walking client listener!
 */
 public class WalkingCL {
private SwingWorker work;


ServerSocket server;
 public boolean listening = true;

public void acceptclient(){
    try {
        System.out.println("Created server socket");

        server = new ServerSocket(4444);
    } catch (IOException e) {
        System.err.println("Error while creating ServerSocket on port 4444");


        e.printStackTrace();
    }
work = new SwingWorker<Object,Void>(){
    public Object doInBackground(){

        while(listening){
            try {
                new WalkingCLT(server.accept()).start();
            } catch (IOException e) {
                System.err.println("Error while making thread!");
                e.printStackTrace();
            }
        }

        return listening;

    }
   };
 }
}

Here is the client listener thread:

package org.walking.server.listener;

import java.io.BufferedReader;
import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.net.Socket;
/*
 * Walking Client listener Thread!
 */
public class WalkingCLT extends Thread {
private Socket client;

public WalkingCLT(Socket client){
    super("Walking client listener thread!");

    this.client = client;

}
@Override
public void run(){
    System.out.println("HELLO?");
    try {
        System.out.println("User:" + client.getInetAddress() + "connected!");

        PrintWriter out = new PrintWriter(client.getOutputStream(),true);
        BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));


        out.println("HELLO?");
        out.flush();



        out.close();
        in.close();
        client.close();

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

}

I’ve put some println statments to see if it comes to that but I only see this:
Server stacktrace:

Created server socket

Client stacktrace:

Panel Created!
Your connected!

Hope you can help me.

Thanks!

  • 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-27T20:56:25+00:00Added an answer on May 27, 2026 at 8:56 pm

    You are only creating an instance of the SwingWorker task. You are missing a call to work.execute() or work.doInBackground() by some helper class. You need to look at the ExecutorService and how to use it to submit and execute SwingWorker tasks. There is also a small code snippet in the Future documentation.

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

Sidebar

Related Questions

I'm making a server/client application in Java but it doesn't really work the way
Hi guys i am making an application for iPhone that will allow user to
I'm working on making a simple server application with python, and I'm trying to
I'm making server that make a tcp socket and work over port range, with
With regards to making a game server, it seems Erlang always comes up as
I'm making AJAX calls to a server that sometimes return unparseable JSON. The server
I have just made my first proper little desktop GUI application that basically wraps
I have an application that is making use of the PhoneGap (version 1.4.1). It
We've got a Java server application that runs on a number of computers, all
I'm making some changes to a legacy classic ASP application. I've made the changes

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.