File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes A question from Java Concurrency in Practice. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "A question from Java Concurrency in Practice." Watch "A question from Java Concurrency in Practice." New topic
Author

A question from Java Concurrency in Practice.

Qunfeng Wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 433
There is a piece of code on Page 40:

It's said bad. Because it will allow the internal states to escape. But the code like this is always common in the application, especially some java beans.

Also according to the book, I find many errors in my application, and in the previous application I ever saw.

What does that mean? It means lots of applications in use have concurrency problems?

Thanks.


To be or not to be. It's a question.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Yes - a lot of code in the world is not thread-safe. Errors like this are fairly common. Writing thread-safe code takes extra attention to detail.


"I'm not back." - Bill Harding, Twister
Qunfeng Wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 433
Amazing!!!

Why do customers buy these softwares?
Bob Ruth
Ranch Hand

Joined: Jun 04, 2007
Posts: 320
Think of it this way,

If you have two blind cooks in the kitchen. One wants to make a chocolate cake, the other wants to make tuna fish casserole. But you only have one mixing bowl.

Cake cook will break two eggs into the bowl, put a cup of sugar in, and then turn to get the flour.

In the meantime, casserole cook will open up a can of tuna, dump it in, then turn to get the mushroom soup when,

Cake Cook comes back and dumps in three cups of flour then goes to get the baking powder.

At this point Casserole Cook comes back, dumps in the mushroom soup, then goes to the pantry to get the pasta,

Now, the Cake Cook comes back dumps in the baking powder and.....

if you get the idea, what two EXCELLENT cooks have created .... was a mess.
Because, access to the bowl was not "synchronized". If the bowl would have been "synchronized" Cake Cook would have gained the bowl, Casserole Cook would have had to wait.

A consumer would have no way of knowing whether the underlying application architecture made proper use of "synchronization" unless they read some reviews first.... because I'd bet if they didn't there would be some reliability problems posted.

Kind of like a "Tuna Fish/Chocolate Cake" !



------------------------
Bob
SCJP - 86% - June 11, 2009
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Made my day, Bob. Thanks!


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42951
    
  72
Also according to the book, I find many errors in my application, and in the previous application I ever saw.

What does that mean? It means lots of applications in use have concurrency problems?


I'm currently reading that book, too. It's frightful in that regard (and quite good, by the way). I've revisited a few pieces of code I've written to fix things I learned from it.
Bob Ruth
Ranch Hand

Joined: Jun 04, 2007
Posts: 320
My pleasure, Stan. Absolutely my pleasure.

I'm always trying to put things in common terms!
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
Originally posted by Louis Wang: Amazing!!! Why do customers buy these softwares?

May I suggest the Meaningless Drivel dsicussion group ? It is said to be "A place to talk about stuff that has nothing to do with Java." though I feel there should be a Reliability engineering discussion group at http://www.javaranch.com for that purpose.

I have had moderate but real success, along with others, working such issues htere as:

  • How many hours do you sleep every day?
  • Which is your best and worst moment of your life?
  • Do you plan to get iPhone ?
  • Analog guitar distortion
  • best place to learn SAP ?
  • Paul Potts - Video
  • Diet Hacks David O'Meara
  • Robots Taking over the World! (and cleaning)
  • Shivaji - To be released
  • "Even I" vs. "I also"
  • Net Nanny, et al
  • DIY: Aphorism


  • "The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: A question from Java Concurrency in Practice.