Date: Thu, 3 Jun 2004 17:02:03 -0600 From: Nate Williams <nate@yogotech.com> To: Ronald Klop <ronald-freebsd7@klop.yi.org> Cc: java@freebsd.org Subject: Re: possible threading problem Message-ID: <16575.44523.933426.867439@emerger.yogotech.com> In-Reply-To: <opr81c9s0xm97yfk@outgoing.local> References: <20040601154601.0869f5b4@psych.iad.vt.edu> <40BD7C06.5050205@noc.ntua.gr> <20040602095245.48cb3c44@psych.iad.vt.edu> <opr8zfpxqaydasmi@outgoing.local> <20040603120810.096a1975@psych.iad.vt.edu> <opr81c9s0xm97yfk@outgoing.local>
next in thread | previous in thread | raw e-mail | index | archive | help
[ Note, I have not analyzed the code in question, but from the sounds of things, the behavior the posted is probably 'acceptable' on FreeBSD. ] > BTW: You interrupt your own thread. The javadoc's say that if the thread > is not blocked it will set the interrupted flag. I think that the next > time a blocking syscall is done the InterruptedIOException is thrown, > because the interrupted flag is set. So the InterruptedIOException can be > thrown at a very different moment than that the thread.interrupt() call > was done. This is right on the money. Different threading models will behave very differently. Prior to JDK1.4 on Solaris (the reference platform), you could get *very* different results by choosing to use green threads vs. native threads. And, things got even more different when you started using a JIT, which could cause behavior that appeared to be non-deterministic. In every good Java book, the use of 'interrupt', 'stop', and any other method stats that the results you get *WILL* be different. Just because one platform behaves a particular way doesn't necessarily mean it's correct (or that any platform is correct). > I'm not sure about this, because I don't know enough about the > internals of java, but it can be the reason, that it looks like a > synchronization problem. In the JVM, or in the code? (I'm guessing the latter, but I want to make sure of your intent). > Printing more debug info, can show you > this. But beware that the printing of the debug info can interfere > with the rest of the program. Back in the good 'ol days (JDK1.0/JDK1.1/JDK1.2 timeframe) when developing a highly-threaded cross-platform product that was deployed on Windows 95/98/NT/2000/FreeBSD/Linux/Solaris, during our testing we found that code that we 'thought' was safe behaved extremely different from platform to platform. It varied from between different M$ OS products, and even varied depending on which JVM was installed. And, for what it's worth, this program has been tested using the FreeBSD JDK1.4 JVM, which should be identical to the environment the poster spoke about. Investigation after investigation showed that in virtually every case, the behavior we were seeing was 'acceptable' if you allowed the thread scheduling to be completely non-deterministic (which is the case with Java). It may not behave like you expect, but it is certainly legal. My .02 worth Nate
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?16575.44523.933426.867439>