In a nutshell: I have a (mutable) list of customers, ordered by surname In thread A, I take that list and display it on a webpage In thread B, I take that same list, sort it by reverse order of when I last phoned them, and display on a different page
Because of the way concurrency works, thread A is interrupted by thread B halfway through displaying the list, needless to say the output is not as expected. So it would have been much safer if the list was immutable and thread B created a copy of it that was sorted differently. Could locks have solved it? Probably, assuming your concurrent programming skills are flawless and you've never encountered a deadlock or race condition in your life, and it's also a pretty steep performance cost once you've scaled up to 100s of threads. On 29 April 2010 15:17, Wildam Martin <[email protected]> wrote: > On Thu, Apr 29, 2010 at 14:41, egervari <[email protected]> wrote: > > How many of you are currently programming in a hybrid language such as > > Scala? > > I don't > > > > I'm finding it difficult to make things immutable. While I am > > definitely using more immutability than I ever have in the past, I > > don't think it's practical for some applications. > > Fine, that I am not the only one thinking that way. And I might never > understand why it is sooo good to have everything immutable. I > definitely want a lot of objects to be mutable. I am dealing with > software and not with statues of stone. ;-) > > -- > Martin Wildam > > -- > You received this message because you are subscribed to the Google Groups > "The Java Posse" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<javaposse%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/javaposse?hl=en. > > -- Kevin Wright mail/google talk: [email protected] wave: [email protected] skype: kev.lee.wright twitter: @thecoda -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
