• Post Reply Bookmark Topic Watch Topic
  • New Topic

Access main thread variable values in callback method  RSS feed

 
Ranch Hand
Posts: 1279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Sheriff
Posts: 23446
46
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sam liya
Ranch Hand
Posts: 1279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!