Java Newsletters Archive: 152
Hello dear friends!
Have you entered yet?
JavaFAQ.nu is proud to announce that we are a sponsor of the March 6 Amber Taylor IT Give-Away promotion. We do not do this very often but thought you would be interested in the products and services for IT Professionals being awarded. There is something for everyone! What is the cost? Not a thing! Enter here. You could win a free 500 Java Tips eBook.
Question: When should I use notify() and when notifyAll() methods on threads?
Answer: Generally it is more reliable to use notifyAll() method. Notify() method wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. A thread waits on an object's monitor by calling one of the wait methods. Since it is internally implemented we do not know exactly which thread will be chosen.
This method should only be called by a
thread that is the owner of this object's monitor. A thread becomes the owner of
the object's monitor in one of three ways:
By executing the body of a synchronized
statement that synchronizes on the object.
It is much safer to use from the
beginning notifyAll() method and later trying to optimize your program you can
try to switch to notify(). You have no idea which thread will be awakened. You
must be sure that every waiting thread will be able to continue if you use
notify() method. The behavior of your program will be more predictable.
Question: The clear-Method in the java.util.Calendar-Class doesnt behave like I suggest. I want to clear the hour-field in a Date. If I use Calendar.clear(Calendar.HOUR) the hour is not reset. If I use Calendar.clear(Calendar.HOUR_OF_DATE) the hour is not reset also. Only if I invoke both methods the hour is reset. (java version "1.2.2")
It is known Java bug.
I need help again, how no! I'm writing an application which generate SVG files. I want to compress this files to use the .svgz extension. I know that it possible use gzip to compress the file, but I wonder if I can use some Java class to do it.
I have tried this code...
image-object as image on the web server..
Problem while trying to make an
executable with Jexegen
If have downloaded MS SDK for Java 4.0
and I wanted to make an executable. After reading some documents about Jexegen I
have to typed this:
Importing .swf Flash file into Java
Please ask your questions and help each
other at our Java Forum:
The Java FAQ Daily Tips is a newsletter that is only sent to those who have specifically subscribed to it (double opt-in).
To subscribe/unsubscribe to "The Java FAQ
Daily Tips" weekly edition newsletter visit our page
If you have troubles please contact us: email@example.com
If you have added a link to
http://javafaq.nu on your WEB-site, please let
us know and you will get listed on our
More information and graphics artworks
can be found here
For information on advertising on the
Java FAQ's Daily Tips Newsletter, send an email to:
Send your comments, questions, praise and complaints to us: firstname.lastname@example.org
Copyright (c) 2000 - 2003 John Andersson, All rights reserved.
Printer Friendly Page
Send to a Friend
Search here again if you need more info!
|Home||Code Examples||Java Forum||All Java Tips||Books||Submit News, Code...||Search...||Offshore Software||Tech Doodling|
|RSS feed Java Forums|