82440

Sending web request and not waiting for response

Question:

I am using this way of sending http get requests at the moment using HttpURLConnection. (<a href="http://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/" rel="nofollow">http://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/</a>)

I was wondering how would I go about not receiving the response from the request or even acknowledge it at all and just needed the request to be fired off as fast as possible how could I achieve this?

Thanks.

Answer1:

What you need is a "fire and forget" semantic, not directly related to http request, rather more to threads. Simply launch whatever your task is, in a new thread

Thread thread = new Thread(new Runnable(){ @Override public void run(){ HttpURLConnectionExample http = new HttpURLConnectionExample(); System.out.println("Testing 1 - Send Http GET request"); http.sendGet(); } }); thread.start();

Recommend

  • Moving and Renaming Files Using VBScript
  • Manual ack with Spring Cloud Stream RabbitMQ
  • message-driven-channel-adapter and multi threading
  • Symfony 3 new project error
  • Is there any standard requirement for C++ #include lookup?
  • staticfiles and STATIC_URL with virrtualenv - django
  • cast stl::vector containing pointers to stl::vector containing constant pointers
  • TFS edit build log using custom activity
  • Jackson mapper write id instead of entire object
  • Extjs, handling success or failure when doing a standard submit in a form
  • Chrome breakpoint on radio doesn't fire
  • How to replace TouchesBegan with UIGestureRecognizer
  • Fire callback when selection was made with select2 4.0, and retrieve the value of last selection
  • Get current user from inside the model in Sails
  • What is this strange character in chrome's resource css viewer?
  • init_seg and warning C4073 from library code?
  • How to repeat sections of a SQL query across UNIONs? (DRY in SQL)
  • EntLib Way to Bind “Null” Value to Parameter
  • Android onKey w/ virtual keyboard
  • How do I Dispose a HttpResponseMessage in my Web Api Method?
  • Change Checkbox value without raising event
  • allocating memory to an array of string
  • Check all values in string[] for length?
  • Django model inheritance, filtering models
  • Reading a file into a multidimensional array
  • Object and struct member access and address offset calculation
  • Force show.bind execution
  • Is there a way to do normal logging with EureakLog?
  • Hardware Accelerated Image Scaling in windows using C++
  • Magento Fatal error: Maximum execution error solution, on WAMP
  • Asynchronous UI Testing in Xcode With Swift
  • Is possible to count alias result on mysql
  • Large data - storage and query
  • Is there a mandatory requirement to switch app.yaml?
  • File upload with ng-file-upload throwing error
  • Python: how to group similar lists together in a list of lists?
  • ExecuteAsync RestSharp to allow backgroundWorker CancellationPending c#
  • AngularJs get employee from factory
  • Benchmarking RAM performance - UWP and C#
  • Understanding cpu registers