Forums Register Login
Access main thread variable values in callback method
I am calling Rest API using AsyncRestTemplate inside a loop. Once callback returns i need to access main thread values. But the issue is i am calling AsyncRestTemplate inside a loop as below .

inside callback i need t oaccess list values. but issue is since this runs  inside a loop when callback comes loop may in a different iteration. So how can i access the same values when i am calling exchange methos ?
You haven't said what's preventing you from using the variables in question, or even what those variables are, but in the absence of that I will just suggest that you declare the variables to be final.

If that isn't the answer you want, then go ahead and post more details.
actually i need to get the value from each callback. for example i have a list which contain 10 items. So that means there will be 10 call backs. So each call back i need to access the list and get relevant  value. For example for the 1st iteration  i need to get 1st value of list, but when callback comes the i value of iteration may changed to different value. So how do i know 1st iteration callback comes which items to get from the list?
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

This thread has been viewed 117 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jan 16, 2018 02:44:49.