possible threading problem
Ronald Klop
ronald at cs.vu.nl
Wed Jun 2 12:43:04 PDT 2004
On Wed, 2 Jun 2004 09:52:45 -0400, Daniel Fisher <daniel.fisher at vt.edu>
wrote:
> On Wed, 02 Jun 2004 10:04:38 +0300
> Panagiotis Astithas <past at noc.ntua.gr> wrote:
>
>> Daniel Fisher wrote:
>> > I'm experiencing a weird threading problem with jdk-1.4.2p6_3 that I
>> don't
>> > see on Linux.
>> > It looks like the BSD JDK is not honoring sychronize statements.
>> > Has anyone seen this before?
>> > If not, who should I send sample code to?
>>
>> Um, the list?
>> --
>> Panagiotis Astithas
>
> Alrighty then....
> attached is a tarball with the sample classes in it.
> Untar and cd into the directory.
> Execute: java -jar prop.jar
> These classes monitor the main.properties file and echo the changes to
> stdout.
> Edit main.properties while the java job is running.
> FreeBSD JVM throws an InterruptedIOException, Linux JVM does not throw an
> exception.
Add debugging like, so you can make sure synchronized is (not) working.
synchronized (a) {
System.out.println("In a 1");
...
System.out.println("Out a 1");
}
If I recompile your program I get other results after modifying the
properties file.
java.lang.NoClassDefFoundError: prop/PropEvent
at prop.PropSingleton.removeProperties(PropSingleton.java:74)
at prop.PropMonitor.run(PropMonitor.java:71)
at java.lang.Thread.run(Thread.java:534)
PropMonitor interrupts itself. Why? it's useless.
By the way if you don't do this your program works.
Offtopic:
In PropMonitor you catch Exception. So you will mis all other possible
error messages from java.
If this is not just a test class I would rewrite it.
Why this:
try {
throw Exception();
} catch (Exception) {
break;
}
You can also just do break in stead of the exception.
And you can remove all the interrupt/interrupted calls. Only keep the
boolean run.
And even nicer than the break is setting run = false to end the while.
But only removing the stopMonitor call from PropMonitor.run() will also
make it work. :-)
Ronald.
--
Ronald Klop
Vrije Universiteit, Amsterdam, The Netherlands
More information about the freebsd-java
mailing list