• 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

what happens if an exception is thrown by barrier action (CyclicBarrier concept)

 
Ranch Hand
Posts: 42
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all Ranchers,

I am new to concurrent program, while reading about CyclicBarrier i have one doubt, that is what happens if an exception is thrown by barrier action (an action supplied to CyclicBarrier to run after reaching the barrier).


Thanks and regrards
Ram
 
Author
Posts: 285
12
Scala IntelliJ IDE Netbeans IDE Python Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The barrier action is defined by a Runnable, which cannot throw a checked exception. It seems reasonable to expect that any unchecked exceptions must be ignored; they surely don't want to be allowed to kill the barrier's management thread

In other words, make sure you add any unchecked exception management code to your action Runnable.
 
rambabu desina
Ranch Hand
Posts: 42
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Simon,

Thanks for your quick reply. but i want to know if we dont write the exceprion management code in barrier action then what will happen to barrier threads.
i mean that do barrier threads continue their execution or throw the BrokenBarrierException?

Regards
Ram
 
Simon Roberts
Author
Posts: 285
12
Scala IntelliJ IDE Netbeans IDE Python Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The thread that happens to execute the barrier action (which is one of the threads that awaits, but I don't believe it's predictable as to which) receives the unhandled exception, the others get a BrokenBarrier.

Why would you not just handle the exception in the barrier action code?
 
reply
    Bookmark Topic Watch Topic
  • New Topic