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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:21:18+00:00 2026-05-18T12:21:18+00:00

Im working on a socket program in Java. Im running a GUI with a

  • 0

Im working on a socket program in Java.
Im running a GUI with a socket server in the background.
The socket server is running a thread that checks for socket messages every 10ms.
Both of them runs fine together but as soon as I try to open my File dialog in the gui, the gui crashes, but the server keeps on running.
Im thinking that I run the server (or the server thread) in a wrong way.
The file dialog works fine if I skip the socket.

What could be the problem, could it be that Im running the thread in a wrong way?

(this in one class)

public ServerController(){
        ServSocket st = new ServSocket();
    Thread thread1=new Thread(st);
    thread1.start();
    }

(this is my thread)

public void run(){
    while (true) {
        try { 
            Thread.sleep(10);
        }
        catch (InterruptedException e) {}

        switch (Status) {
        case CONNECTED:
            try {

                socket = new Socket(hostIP, port);
                System.out.println("Connected on: " + hostIP + port);

                out = new PrintWriter(socket.getOutputStream(), true);
                changeStatus(STARTSENDING, true);
            }
            catch (IOException e) {
                System.out.println("disconnected");
            }
            break;

(and this is my main)

 static ServerController scon;
 static Controller cn;

 public static void main(String[] args) {
     scon = new ServerController();
      cn = new Controller();
     cn.gui();


      }
  • 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-18T12:21:18+00:00Added an answer on May 18, 2026 at 12:21 pm

    The problem is now solved.
    Seems that the problem was that i had a scanner that was waiting for input(string = sc.next();) every 10ms in the thread, and after a few input my GUI showed.
    I removed the Scanner and i now have a working application.

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

Sidebar

Related Questions

for some reason my server that uses socket.io is not working properly. The program
I'm working on a project for my company that uses a socket server (php)
I am working on a java program that is essentially a chat room. This
I am working on a practical scenario related with Java;a socket program. The existing
Is this even possible? I have a java server program on a mac that
I'm working on a socket program and everything seems fine when compiling. First I
I'm trying to get a simple winsock program working, so I create my socket
I'm working on some code that reads from a socket, and it goes wrong
Okay, so I'm working on a project where I use a Java program to
A part of an application I'm working on is a simple pthread-based server that

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.