The Artima Developer Community
Sponsored Link

Java Community News
Visualizing Concurrency

19 replies on 2 pages. Most recent reply: Apr 23, 2008 6:50 AM by James Watson

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 19 replies on 2 pages [ « | 1 2 ]
James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: Visualizing Concurrency Posted: Apr 22, 2008 8:37 PM
Reply to this message Reply
Advertisement
> 1) i hope you are writing your question on a whiteboard as
> code because i parsed the English a different way from
> what i now think i see you meant. so it ends up being more
> about "can we communicate" than "do you know concurrency
> in java?"

I often wonder about whether I am stating this as clearly as I wish. In fact, this has never been a question that eliminates a candidate because we would never hire anyone if it was. But on the other hand, it is a good communication test.

> 2) just because Strings are immutable doesn't mean s can't
> be reassigned leading to a race condition. that may or may
> not be relevant, it depends on context.

Whether s is reassigned I or not I don't think it matters because toString() isn't synchronized on anything.

Mark Thornton

Posts: 275
Nickname: mthornton
Registered: Oct, 2005

Re: Visualizing Concurrency Posted: Apr 23, 2008 12:37 AM
Reply to this message Reply
> because toString() isn't synchronized on anything.

How do you know? The class documentation for String doesn't contain any mention of synchronization. You either have to examine the source code or deduce it from the mention of immutability.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: Visualizing Concurrency Posted: Apr 23, 2008 6:03 AM
Reply to this message Reply
> > because toString() isn't synchronized on anything.
>
> How do you know? The class documentation for String
> doesn't contain any mention of synchronization.

Clue 1.

> You either
> have to examine the source code

Clue 2.

> or deduce it from the
> mention of immutability.

Clue 3.

Mark Thornton

Posts: 275
Nickname: mthornton
Registered: Oct, 2005

Re: Visualizing Concurrency Posted: Apr 23, 2008 6:06 AM
Reply to this message Reply
Yes, you have clues but no documented formal guarantee that I am aware of.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: Visualizing Concurrency Posted: Apr 23, 2008 6:50 AM
Reply to this message Reply
> Yes, you have clues but no documented formal guarantee
> that I am aware of.

You mean other than the source?
public String toString() {
    return this;
}


In any event, is this reall important? It's not the point of the question. As I pointed out before, if the candidate is unsure, they can ask whether String.toString() is synchronized or not. If they assume it is, that's not a very good sign. If they are unsure and don't ask, that's bad too. If you really understand Java synchronization the question is trivial and my intention in asking it should be fairly transparent.

Flat View: This topic has 19 replies on 2 pages [ « | 1  2 ]
Topic: An Introduction to Django Previous Topic   Next Topic Topic: JetBrains Releases Structure101

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use