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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:15:34+00:00 2026-05-20T16:15:34+00:00

I have a java client which is managing its server calls in new threads

  • 0

I have a java client which is managing its server calls in new threads to prevent the GUI from freezing.

Even if this is prevented in many places, it is possible that the method will be called again on the same model, for example with different parameters. In such case, I obviously want the newest call, with the most up to date parameters, to be the one “succeeding” and displaying its results.

I have a system which is keeping track of the previously launched Thread, and interrupts it before launching the new one (Thread.interrupt()). The other methods are then checking if they are running in a non-interrupted thread (using if (Thread.currentThread().isInterrupted()) before firing the new results to the GUI elements.

This structure was working with a previous connector to the server, as I was the only one checking the interrupt flag on the process. My problem is that I’m now using EJB method calls in the client, and they react badly to the interrupted thread. Interrupting the Thread during an EJB call will trigger a RuntimeException which is including an InterruptedException. And it doesn’t seem like a normal thing to happen.

Obviously I could catch RuntimeExceptions in every server call and check their cause for the interrupt, but it doesn’t seem very “clean”.

My question is: what can I do in such context? What is the proper way to interrupt a Thread running an EJB method call?

  • 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-20T16:15:34+00:00Added an answer on May 20, 2026 at 4:15 pm

    Given the existing architecture, I finally went with catching the RuntimeException from each server call, in such form:

    try {
        return getEJBService().getServiceResult(param, param, param);
    } catch (RuntimeException e) {
        Throwable cause = e.getCause();
        if (cause instanceof InterruptedException)
            throw (InterruptedException)cause;
        else
            throw e;
    }
    

    It’s not really pretty, but at least it allows me to act according to the interruption with my current model.

    In the ideal world, one should rather go with one of the solutions given by Rich.

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

Sidebar

Related Questions

I have a Java Client which sends UTF-8 strings to a C# TCP-Server, I'm
I have a Java client that calls a web service at the moment using
I have a client-server application written in Java using CORBA for the communication. The
i have a server - client application that runs on java 1.3; i want
I have a java client that is calling a web service operation which takes
I have a java client program that uses mdns with service discovery to find
I have Java and Flash client applications. What is the best way for the
I have some model objects I'm using in my Java client application. Later these
I have a java back-end that needs to expose services to clients running in
Here is what I have: JAVA_HOME=C:\Software\Java\jdk1.5.0_12 (points to JDK 5.0) In Eclipse Installed Runtimes

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.