0

I am a java beginner, I met a problem in my Restful class, I just wonder when my code is working on the Restful Class, like the thread is still working on one url request, at the same time I send another request to invoke the same Restful Class, this can work properly or not? Now, I set a client using "GET" method. Do I need to change the method "GET" so the thread does not need to wait to the "Response"?

Any help, thanks a lot~

Dudu
  • 5
  • 1

1 Answers1

0

When you are using a framework, things are very easy. To answer your questions

  • How does the class behave when two simultaneous requests are made?

Each of your request will run in a separate thread. So its as simple as two different threads accessing a method simultaneously. Care must be taken not to use any shared resources (including instance variables) in the method. In that case, this becomes a bit tricky.

  • Do I need to change the method "GET" so the thread does not need to wait to the "Response"?

I am not sure what you mean by this. When you use HTTP, a request will always be accompanied by a response. That's how the the protocol works. Even in case of an asynchronous scenario, an immediate notional response is always returned.

Santosh
  • 17,667
  • 4
  • 54
  • 79