• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question from Java Concurrency in Practice.

 
Qunfeng Wang
Ranch Hand
Posts: 434
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amazing!!!

Why do customers buy these softwares?
 
Bob Ruth
Ranch Hand
Posts: 320
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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" !

 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Made my day, Bob. Thanks!
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 320
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My pleasure, Stan. Absolutely my pleasure.

I'm always trying to put things in common terms!
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

  •  
    Consider Paul's rocket mass heater.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic