groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 12/18: Trivial refactoring: Anonymous type has shorter lambda alternative
Date Sun, 03 Nov 2019 15:42:28 GMT
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 8504c0019948716d643214d4c0aed161b6b9ce50
Author: Daniel Sun <sunlan@apache.org>
AuthorDate: Sun Nov 3 22:52:43 2019 +0800

    Trivial refactoring: Anonymous type has shorter lambda alternative
    
    (cherry picked from commit 0456dfa8b072581dd0fca3a12f5e937085545863)
---
 .../org/codehaus/groovy/util/ReferenceManager.java | 38 ++++++++++------------
 1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/util/ReferenceManager.java b/src/main/java/org/codehaus/groovy/util/ReferenceManager.java
index 6ab6d56..9bcc168 100644
--- a/src/main/java/org/codehaus/groovy/util/ReferenceManager.java
+++ b/src/main/java/org/codehaus/groovy/util/ReferenceManager.java
@@ -28,28 +28,26 @@ public class ReferenceManager {
         private volatile boolean shouldRun = true; 
         public ThreadedReferenceManager(ReferenceQueue queue) {
             super(queue);
-            thread = new Thread() {
-                public void run() {
-                    ReferenceQueue queue = getReferenceQueue();
-                    java.lang.ref.Reference r=null;
-                    while (shouldRun) {
-                        try {
-                            r = queue.remove(1000);
-                        }  catch (InterruptedException e) {
-                            break;
-                        }
-                        if (r==null) continue;
-                        
-                        if (r instanceof Reference) {
-                            Reference ref = (Reference) r;
-                            Finalizable holder = ref.getHandler();
-                            if (holder!=null) holder.finalizeReference();
-                        }                  
-                        r.clear();
-                        r=null;
+            thread = new Thread(() -> {
+                ReferenceQueue queue1 = getReferenceQueue();
+                java.lang.ref.Reference r=null;
+                while (shouldRun) {
+                    try {
+                        r = queue1.remove(1000);
+                    }  catch (InterruptedException e) {
+                        break;
                     }
+                    if (r==null) continue;
+
+                    if (r instanceof Reference) {
+                        Reference ref = (Reference) r;
+                        Finalizable holder = ref.getHandler();
+                        if (holder!=null) holder.finalizeReference();
+                    }
+                    r.clear();
+                    r=null;
                 }
-            };
+            });
             thread.setContextClassLoader(null);
             thread.setDaemon(true);
             thread.setName(ThreadedReferenceManager.class.getName());


Mime
View raw message