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

  • Home
  • SEARCH
  • 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 6657333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:45:17+00:00 2026-05-26T01:45:17+00:00

Consider you have the following code implementation of a timer in a net game:

  • 0

Consider you have the following code implementation of a timer in a net game:

public void DefineTimer()
    {
            Action updateClockAction = new AbstractAction() {
                public void actionPerformed(ActionEvent e){

                    //System.out.println(javax.swing.SwingUtilities.isEventDispatchThread());

                     JPanelMainGame.this.jLabelSeconds.setFont(new java.awt.Font("Lucida Handwriting", 1, 36));
                     JPanelMainGame.this.jLabelSeconds.setForeground(Color.red);
                     JPanelMainGame.this.jLabelSeconds.setText(Integer.toString(JPanelMainGame.this.m_TimerTotalSeconds));

                    if( JPanelMainGame.this.m_TimerTotalSeconds >0)
                    {
                         JPanelMainGame.this.m_TimerTotalSeconds--;
                    }
                    else if ( JPanelMainGame.this.m_TimerTotalSeconds == 0)
                    {
                       // System.out.println(javax.swing.SwingUtilities.isEventDispatchThread());
                        JPanelMainGame.this.m_Timer.stop();
                        JPanelMainGame.this.jLabelSeconds.setText("0");
                        JPanelMainGame.this.jButtonFinish.setVisible(false);
                        System.out.println("after JbuttonFinish set visble false");
                        System.out.println("!m_WasGameDecisived: "+!m_WasGameDecisived);
                       // System.out.println(javax.swing.SwingUtilities.isEventDispatchThread());
                        JPanelGameApplet gameApplet = (JPanelGameApplet) getTopLevelAncestor();
                        //Checking whether time ended for both players and no solution was recieved

                        if(gameApplet.GetJPanelChooseGame().GetGameType() == eGameType.Net)
                        {

                            gameApplet.GetClinetThread().UpdateServerOfTimeEnded();
                            System.out.println("After Update");
                            if (!m_WasGameDecisived)
                            {
                                // System.out.println(javax.swing.SwingUtilities.isEventDispatchThread());
                                System.out.println("Tie - No one had a solution in the given time");


                                gameApplet.GetClinetThread().SendRequestToClosePlayerThreadAndRemoveItFromPlayersOnServer();
                                System.out.println("After SendRequestToClosePlayerThread");
                                gameApplet.GetClinetThread().CloseSocket();
                                System.out.println("After CloseSocket");
                                Menu.BrowseTo(PanelMenuNumber.k_ChooseGame, JPanelMainGame.this.getParent());
                                //askUserForAnotherRoundLeaveTableOrExitProgram();//////////////////////////////////////////////To implement
                            }
                        }
                        else if(gameApplet.GetJPanelChooseGame().GetGameType() == eGameType.Single)
                        {
                            JPanelMainGame.this.showPopUpSelectionBar();

                        }
                    }
                }
            };
            m_Timer = new Timer(1000, updateClockAction);
    }  

I have added these functions (which write to the same DataOutputStream:

gameApplet.GetClinetThread().UpdateServerOfTimeEnded();

gameApplet.GetClinetThread().SendRequestToClosePlayerThreadAndRemoveItFromPlayersOnServer();

After adding them I get inconsistent exceptions:
Sometimes I get exception in the client because one of the functions, or both or not having any exception at all.
Please help me figure out the problem
Example for exceptions I get from time to time:

java.net.SocketException: Software caused connection abort: socket write error
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:115)
        at java.io.DataOutputStream.writeInt(DataOutputStream.java:181)
        at GUI.ClientCommunicationThread.UpdateServerOfTimeEnded(ClientCommunicationThread.java:851)
        at GUI.JPanelMainGame$2.actionPerformed(JPanelMainGame.java:313)
        at javax.swing.Timer.fireActionPerformed(Timer.java:271)
        at javax.swing.Timer$DoPostEvent.run(Timer.java:201)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
java.net.SocketException: Software caused connection abort: socket write error
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:115)
        at java.io.DataOutputStream.writeInt(DataOutputStream.java:180)
        at GUI.ClientCommunicationThread.SendRequestToClosePlayerThreadAndRemoveItFromPlayersOnServer(ClientCommunicationThread.java:825)
        at GUI.JPanelMainGame$2.actionPerformed(JPanelMainGame.java:327)
        at javax.swing.Timer.fireActionPerformed(Timer.java:271)
        at javax.swing.Timer$DoPostEvent.run(Timer.java:201)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
  • 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-26T01:45:18+00:00Added an answer on May 26, 2026 at 1:45 am

    ‘From within a Swing timer’ indicates a design flaw as per the comments to your question, but the exception itself is simply a network error and has nothing to do with Swing at all. There is a Microsoft Knowledge Base article about it, which you should read, but in brief this exception with this error text indicates that the local TCP stack has given up writing to that connection due to prior network send problems.

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

Sidebar

Related Questions

I have a question about .net generics. Consider the following code: public abstract class
Consider I have the following interface: public interface A { public void b(); }
Please consider the following three .NET types: I have an interface, an abstract class,
Consider the following code. public interface IFoo { } public class Bar { public
Consider the following code: // MyClass.h @interface MyClass @property NSInteger Value; @end //MyClass.m @implementation
I have some gaps in the understanding of string::assign method. Consider the following code:
Let's say I have the following code: typedef std::function<void ()> func_type; void some_func() {
Consider the (highly simplified) following case: class Dispatcher { public: receive() {/*implementation*/}; // callback
I have the following code: require 'rubygems' require 'net/http' require 'uri' url = URI.parse('http://servername.tld/up.txt')
Let's consider the following code: SimpleDateFormat sdf = new SimpleDateFormat(HH:mm:ss dd/MM/yyyy, Locale.US); long start

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.