Olaf Kummer

Greenhorn
+ Follow
since May 02, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Olaf Kummer

The problem is that you are inserting an ampersand (&) directly into XML text, where it indicates an entity escape. Use & to get an ampersand character into your text property.

Originally posted by xy zhang:
but to a big website, the threads will be interrupted due to the famous Java heap size, outofmemory issue. I ever tried to set the -Xmx, but it seems question can not be solved.


This is probably not a concurrency issue. Have you tried to reduce the number of threads to 1?

How does the application react to increasing the heap size? Does it take linearly longer until the application fills up? Have you searched for possible memory leaks like global hash maps, thread locals, or job lists?

You may want to run a memory profiler like Optimizeit.

Olaf

[ August 15, 2005: Message edited by: Olaf Kummer ]
[ August 15, 2005: Message edited by: Olaf Kummer ]

Originally posted by janki tangeda:
I agree that the t1 thread is invoking a block synchronised on sa but that block is in a different class i.e class A???



Yes, they are different classes, but they synchronize on the same object: the array that is passed into the other class. Note that this is not a synchronized method, but a synchronized(...){} statement.

Regards, Olaf
This is the intended behavior. Use wait() when you want other threads to change the state of the guarded variables. When you want to wait for an unrelated condition, synchronize and wait on a separate object. Note that you will have to steer around deadlocks carefully in this case.

Olaf

Originally posted by Rick O'Shay:
The emphasis is important. If B extends A it has access to String foo. If C extends B, String foo is private for all intents and purposes. C will not have access to String foo even.



I could not believe that and I tried it out. Result: C can access foo. That is what I got from the language specification and that is what Sun's 1.4.2 compiler thinks.

Olaf
18 years ago

Originally posted by Javeo Lineo:
Can you help because my I need to change the something regarding Threads, my friend told me not to use "while loop" but instead try to use a "Timer", but I'm not familiar with it...



Your friend refers to javax.swing.Timer. See the javadoc of that class, it is helpful.

Other than that, a general rule is to modify Swing objects in the AWT event queue thread and only there. Modifying them in other thread can cause bizzare and typically undesired effects.

Note that you might (alternatively) encapsulate the setting of the global variable in a method, which updates the Swing component. The update would have to be decoupled from the setter by means of the method javax.swing.SwingUtilities.invokeLater(Runnable). Here, too, I'd like to point at the javadoc.

Regards, Olaf

Originally posted by Stan James:
When you add an item to queue you notifyAll() that something has arrived. That will cause an InterruptedException in *all* of your worker threads.



No. Object#notifyAll() will wake up all threads that might happen to be in an Object#wait(), but it will never send an InterruptedException and it will not get you out of a sleep call or the like..

Regards, Olaf
Small improvement: You compute zre*zre and zim*zim twice, when a single multiplication would suffice. Use: while (true) {... if (...) break; ...}. Adding a number to itself is often faster than multiplying it by two.

That's going to earn you a few percent, but nothing impressive.

Maybe(!) fixed point arithmetic with ints/longs can buy you another few percent, but that requires some thought.

Olaf
18 years ago
Interrupting a thread is an option when you have to get it out of blocking I/O. In general, be careful which operations you do in a thread that might get interrupted, because there is lots of code out there that does not handle interruptions properly. Take special care, when you use external libraries.

Regards, Olaf
As a guideline, 1.5 is harder and there are fewer resources for preparation.

On the other hand, 1.4 contains more trick questions, which definetely need preparation.

1.4 will not be obsolete for a few years to come. But getting 1.5 early might make you more interesting.

Bye, Olaf
I got my result (87%) on Friday and I live in Germany. So it's not only US residents that can hope for their score soon.

Regards, Olaf
18 years ago