Originally posted by Paul Clapham:
Which is pretty much like the code you posted, now that I stare at it for long enough. I don't like it either, but I can say why. When the referenced object disappears and all you're left with is the "shell" SoftReference object, then the hashCode changes and the meaning of equals changes. I don't like that. You could deal with the hashCode problem by storing it in an instance variable the first time you calculate it from the referenced object. The equals problem I don't know -- maybe you should reload the referenced object if it isn't there.
Originally posted by trebor iksrazal:
The code below attempts to do InetAddress.isReachable() on all possible IP's in a subnet, and try to do snmp walk on those that respond. This code works ok, albeit slowly - 25 seconds on a class A subnet. Even worse, on a big class A subnet, I get "java.net.ConnectException: No buffer space available" after around 1000 InetAddress.isReachable() calls.
Originally posted by Nicholas Carrier:
Ok I'm looking at the API and I can create Thread like objects in two diff
Now, in writing this post I think I found my own answer. The reason that you can create it in two different ways is because of the difference between implementing something and extending something. Whereas if it "is a" thread you would extend it, but if it "is something else" then you can implement Runnable so that you get the benefits of the Thread class without the deadly diamond of death problem.
Can someone just let me know if I am right, thanks?
Originally posted by Tejas Chachcha:
Is there any solution to this scenario? If we want to make access from different jvms synchronized? Does it mean that synchronization/threading can make java somewhat plateform independent?
Originally posted by Drew Lane:
Hmmm...this seems more complicated than I had hoped. I probably didn't explain this very well, either.
I actually don't have any other of my own threads running at this point (I was actually referring to the AWT thread, etc.).
So, the main thing I want to accomplish is that the for loop is completed and the buf array is always full when the user tries to save the file by pressing a button. What's been happening is that sometimes the array gets partially full and I get a partial (corrupt) file saved.
Unfortunately, I have to use that for loop to read() the file due to some bugs in the implementation I'm using. It's the only method that seem to work consistantly.
From looking at the code that was posted, I like the idea of the wait/notify. Can I use this concept with the gui I made so that when the user pushes the button to save the file, it will wait until it's notified by the thread that the for loop has completed?
Maybe I just need to make the run method synchronized?
I hope this is more understandable.
Originally posted by ShihChao Lin:
Can anyone tell me why the synchronized for following code does not work?
I was hoping the output will be
But the result was
Thanks for your help
Originally posted by sun par:
I am new to Swing, so I guess I misinterpreted.. This was what I read from jfc unleashed chapter 2