From 2f54a73fc1a1466dbe576bfe0aab80cea9d4ff93 Mon Sep 17 00:00:00 2001 From: David Daney Date: Sat, 20 Sep 2003 02:57:07 +0000 Subject: [PATCH] Reference.java (clear): Set referent to null and synchronize. 2003-09-19 David Daney * java/lang/ref/Reference.java (clear): Set referent to null and synchronize. From-SVN: r71597 --- libjava/ChangeLog | 5 +++++ libjava/java/lang/ref/Reference.java | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index a7648b38e24..4d5c52ec368 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2003-09-19 David Daney + + * java/lang/ref/Reference.java (clear): Set referent to null and + synchronize. + 2003-09-19 Michael Koch * gnu/java/nio/NIODatagramSocket.java, diff --git a/libjava/java/lang/ref/Reference.java b/libjava/java/lang/ref/Reference.java index 2f6235e3ba8..a6385a81617 100644 --- a/libjava/java/lang/ref/Reference.java +++ b/libjava/java/lang/ref/Reference.java @@ -176,7 +176,12 @@ public abstract class Reference */ public void clear() { - cleared = true; + // Must synchronize so changes are visible in finalizer thread. + synchronized (lock) + { + referent = null; + cleared = true; + } } /**