Skip to content

Commit

Permalink
Fix codacy issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
mnlipp committed Apr 29, 2024
1 parent e999747 commit b6614aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public class ManagedBufferStreamer {

private ManagedBufferReader reader = new ManagedBufferReader();
private final ManagedBufferReader reader = new ManagedBufferReader();

public ManagedBufferStreamer(Consumer<Reader> processor) {
Thread thread = new Thread(() -> {
Expand Down
11 changes: 11 additions & 0 deletions org.jgrapes.io/src/org/jgrapes/io/util/ThreadCleaner.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public class ThreadCleaner {
private static ReferenceQueue<Object> abandoned
= new ReferenceQueue<>();

private ThreadCleaner() {
// Utility class
}

/**
* Weak references to an object that interrupts the associated
* thread if the object has been garbage collected.
Expand Down Expand Up @@ -84,6 +88,13 @@ public RefWithThread(Object referent, Thread thread) {
watchdog.start();
}

/**
* Watch the referent and terminate the thread if it is
* garbage collected.
*
* @param referent the referent
* @param thread the thread
*/
public static void watch(Object referent, Thread thread) {
watched.add(new RefWithThread(referent, thread));
}
Expand Down

0 comments on commit b6614aa

Please sign in to comment.