Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/771#discussion_r35632056
  
    --- Diff: usage/cli/src/main/java/brooklyn/cli/Main.java ---
    @@ -964,4 +979,35 @@ public ToStringHelper string() {
         protected Class<? extends BrooklynCommand> cliDefaultInfoCommand() {
             return DefaultInfoCommand.class;
         }
    +    
    +    public static class AppShutdownRequestListener implements 
ShutdownRequestListener {
    +        private AtomicBoolean mutex = new AtomicBoolean();
    +
    +        @Override
    +        public void onShutdownRequest() {
    +            synchronized (mutex) {
    --- End diff --
    
    FYI (completely different topic really!) I'm toying with a new heuristic 
that use of "synchronized" should be considered a warning sign in most code; it 
could use things like `CountDownLatch`, `ConcurrentHashMap`, etc; or one could 
extract the concurrency-handling logic into a wrapping class or into a 
different threading model (e.g. actor-based, or "channels").
    
    I like Go's slogan: "Do not communicate by sharing memory; instead, share 
memory by communicating."
    
    Obviously `synchronized` is the right thing to do sometimes, but it's used 
far too often.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to