Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Executor and Runnables  RSS feed

 
Marco Di Baggio
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Community,

Can someone review this and tell me what I might be doing wrong?





To begin with, the code runs without error and does create a new threads for each report to tun, however, the report running is always the same report
not .. it is as if the same object is used for each thread.

Someone please ... thank-you kindly
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got something called reportListToRun where you're getting those Report objects -- how do you know they are not all the same object?
 
Marco Di Baggio
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Paul,

I the reportListToRun is just a list of report objects, each having a different reportId ... I have verified the different objects exists in the reportListToRun as each has different properties (when I review via debugging) .. however, when the invokeAll(...) is executed the same report is used for each thread.

For example:

If I add two reports to my calllableList (say, reportId=123 and reportId=456) via:



then invoke the invokeAll(...):



Two new threads are correctly created, however, they both contain reportId=123 and are not unique.

Looking for any assistance.
Thank-you for your time and kind regards
 
Marco Di Baggio
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again,

I can definitely confirm confirm that when I add (for example) a second object into my callableList, it is being added, but also overwriting the first element already in the list.



Not sure what to do or why this would occur.
Any thoughts anyone?
Thank-you kindly
 
Marco Di Baggio
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again,

I think the problem is because my reportRunner is an autowired class in spring?



Its not spawning an new reportRunner for each thread.

Any help? Anyone?
Thank-you kindly
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!