• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Concurrency and AspectJ

 
Ranch Hand
Posts: 75
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hope this is the right place for this question...I have a main class



It is advised by the following aspect:


ProcessOne and ProcessTwo are classes that have methods to display the lists. The problem is with line 46 in the aspect, I don't know what this should return. The idea is that if the list is not empty the code should proceed with the call to ProcessOne or ProcessTwo, and if the list is empty then do not execute the call. This works with lists that have data, but as you can see by line 38 in StartPoint, the list is empty. The return null causes the newP1List = p1Service.take().get(); at line 41 to sit and wait. Any thoughts?

TIA.
 
Emil Jennings
Ranch Hand
Posts: 75
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After some more thought, I had to change the aspect up a bit to:



Instead of checking for an empty list at the call, it is checked at execution. Also the aspect is used on a percflow basis so a separate instance of the aspect is created by each submit statement in StartPoint. I separated the two interfaces in case I want to implement of methods that may use this aspect but may only need one of the interfaces. StartPoint was also slightly changed to:



So this is one way lists can be checked to see if they are empty in a program that uses concurrency. I know that the .isEmpty() could've been used, but when you're working with a bunch of lists in a single method .isEmpty() gets redundant and since one of the purposes of AspectJ is to remove this sort of redundant code, I thought this was a good idea.
 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic