Giter Club home page Giter Club logo

Comments (3)

rahulrnitc avatar rahulrnitc commented on August 15, 2024

Hi, thank you for your comments. This looks to be a valid issue and the team is actively looking into it. We will update this issue when a fix is in place.

from sdk-java.

vijayabraj avatar vijayabraj commented on August 15, 2024

Hi @georgantasp , the SDK's HttpUtility postData method is written that way for the following reasons:
a. New thread is created for every request execution so that it does not block other requests or become unresponsive.
b. Invoking the shutdown() will only initiate the shutdown process and it will execute all the tasks submitted to it before shutdown has been called. So that race condition will not occur.
c. future.get() has to be called to get the response from the future object and return it to the user immediately.

from sdk-java.

georgantasp avatar georgantasp commented on August 15, 2024

Hi,

I'm pretty far removed from this concern at this point, but if I have time, I'll put together a PR to show you want I mean.

a. Creating new threads is expensive. The point of the executors package is to make it easy for developers to work with thread pools. In this way, a pool of 10 threads (for example) can be created and reused.
b. You're correct. docs
c. You are misunderstanding the point of threads. In a. you are saying that you don't want the calling thread to block, then in c. you are blocking the thread. If you want to be asynchronous, return the future itself and let the user decide if they want the thread to block.

I would encourage you to read "Java Concurrency In Practice" http://jcip.net/ . It's a great resource for learning more.

from sdk-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.