GUI hangs on socket loop

Posted on 2005-05-11
Last Modified: 2010-03-31
I'm writing a server wich can be started using a gui. When I click on a button to start my server, the gui hangs. I tried to solve it by creating 2 threads, one for the gui, and one for the server, but still no change. How can I solve this ?

Some code:

public class RiotServerGUI extends javax.swing.JFrame {
    private RiotServer server;
    private Thread serverThread;
    private Thread guiThread;
    public RiotServerGUI() {
        serverThread = new Thread(new Runnable() {
                public void run() {
                    server = new RiotServer();
                public void stop() {
        guiThread = new Thread(new Runnable() {
            public void run() {
      ; // Run gui


private void tglConnectActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
        if (tglConnect.isSelected()) {
            // Start serverthread.
        } else {
Question by:Reggie_BE
    LVL 9

    Accepted Solution

    What if you call start() instead of run() ?


    Author Comment

    OMG, that's all ?
    Ok thnx :)
    LVL 9

    Expert Comment

    Don't know if it solves all but even though the method is called run() the thread should be started with a call to start() :)


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Title # Comments Views Activity
    squareUp  challenge 22 80
    Convert BufferedReader to File 1 49
    What is JNDI datasource in spring 1 18
    pairs challenge 5 29
    If you have upgraded to Java2 update 10 on a Microsoft Windows client, you may have discovered that your Java application does not work as it did before.  For example, the colors of your Java2D graphic may be all wrong for no apparent reason. Aft…
    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now