From: rog@vitanuova.com
To: 9fans@cse.psu.edu
Subject: Re: [9fans] Re: advantages of limbo
Date: Tue, 2 Mar 2004 15:03:12 +0000 [thread overview]
Message-ID: <ba1d5fce00018498c7b91b0d698cbd64@vitanuova.com> (raw)
> Class Thread is not a part of the language. 'synchronized'
> is. What's wrong with Java synchronization? Can you please
> bring an example in Java and limbo where Java's synchronization
> is bad while limbo's approach is right?
a selection from Allen Holub's "Taming Java Threads":
: The "synchronised" keyword has several flaws:
:
: 1. You cannot specify a timeout value.
: 2. You cannot interrupt a thread that is waiting to acquire a lock.
: 3. You cannot safely acquire multiple locks.
: [...]
:
: The wait()/notify() system also has problems:
: 1. There is no way to detect whether wait() has returned normally
: or because of a timeout.
: 2. There is no way to implement a traditional condition variable
: that remains in a "signalled" state.
: 3. Nested-monitor lockout can happen too easily.
:
: [...]
:
: More facilities should be added to the language to support inter-thread
: communication. Right now, the PipedInputStream and PipedOutputStream
: classes can be used for this purpose, but they are much too inefficient for
: most applications.
:
: [...]
:
: Access to partially constructed objects should be illegal.
: The JLS currently permits access to a partially constructed object.
: For example, a thread created within a constructor can access the object
: being constructed, even though that object might not be fully
: constructed.
:
: [...]
:
: The lack of good access control makes threading more
: difficult than necessary. Often, methods don't have to
: be thread safe if you can guarantee that they be called
: only from synchronised subsystems.
:
: [...]
:
: The notion of immutability [...] is invaluable in multithreaded
: situations since read-only access to immutable objects doesn't
: have to be synchronised. Java's implementation of immutability
: isn't tight enough for two reasons:
:
: 1. It is possible for an immutable object to be accessed before it's
: fully created and this access might yield an incorrect value
: for some field.
: 2. The definition of immutable [...] is too loose: Objects addressed by
: final references can indeed change state, even though the reference
: itself cannot change state.
:
: [...]
:
: There is also the problem that both class-level (static) and instance (non-static)
: methods can directly access class-level (static) fields. This access is
: dangerous because synchronising the instance method doesn't
: grab the class-level lock, so a synchronised static method can
: access the class field at the same time as a synchronised instance
: method.
:
: [...]
:
: The singleton-destruction problem discussed in Chapter 7 is a serious one.
: [in chapter 7:]
: There is a serious impediment to the correct implementation of Singleton:
: How do you get rid of the thing? The Singleton object is created on
: first use, but what if global resources like temporary files or database
: connections are created by the Singleton's constructor? How do you
: get rid of the temporary file or close the database connection in an
: orderly way? [...] Though I hate to end this section on a pessimistic note,
: I don't have an ideal solution to this problem. If you do, please write to me.
:
: [...]
:
: Daemon threads are shut down abruptly when all the non-daemon
: threads terminate. This is a problen when the daemon has created
: some sort of global resource (such as a database connection or a temporary
: file), but hasn't closed or destroyed that resource when it is terminated.
:
: [...]
:
: The suspend() and resume() methods should just be put back into
: Java. They're useful, and I don't like being treated like a kindergartener:
: Removing them simply because they are potentially dangerous - a thread
: can be holding a lock when suspended - is insulting. Let me decide
: whether or not I want to use them.
:
: [...]
:
: You should be able to interrupt any blocking operation, not just
: wait() and sleep(). [...] Right now, the only way to interrupt a blocking
: I/O operation on a socket is to close the socket, and there's no
: way to interrupt a blocking I/O operation on a file.
with all of these issues, Limbo either ducks the issue (by not
pretending to solve a problem it can't solve properly) or does things
right.
next reply other threads:[~2004-03-02 15:03 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-02 15:03 rog [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-03-03 7:37 YAMANASHI Takeshi
2004-03-03 12:29 ` boyd, rounin
2004-03-03 7:21 YAMANASHI Takeshi
2004-03-03 7:29 ` Kenji Okamoto
2004-03-03 7:31 ` Kenji Okamoto
[not found] <d02d8014f5f4b58c6863ec7a3cd652ee@proxima.alt.za>
2004-03-02 9:07 ` David Tolpin
2004-03-02 10:04 ` lucio
2004-03-02 10:08 ` Fco.J.Ballesteros
2004-03-02 11:35 ` matt
2004-03-02 18:38 ` boyd, rounin
2004-03-02 19:03 ` Fco.J.Ballesteros
2004-03-02 19:10 ` rog
2004-03-02 19:08 ` Fco.J.Ballesteros
[not found] <918d202b192f1bcb8dd969285010a329@proxima.alt.za>
2004-03-02 8:37 ` David Tolpin
2004-03-02 8:02 David Presotto
2004-03-02 8:20 ` David Tolpin
2004-03-02 8:55 ` David Presotto
2004-03-02 9:20 ` Rob Pike
[not found] <f62d09b11d1f097b3f4b5f6b70b65ea5@proxima.alt.za>
2004-03-02 6:58 ` David Tolpin
2004-03-02 7:06 ` Fco.J.Ballesteros
2004-03-02 7:08 ` David Tolpin
2004-03-02 7:14 ` Fco.J.Ballesteros
2004-03-02 7:30 ` David Tolpin
2004-03-02 7:37 ` Fco.J.Ballesteros
2004-03-02 7:48 ` David Tolpin
2004-03-02 9:50 ` Fco.J.Ballesteros
2004-03-02 20:50 ` Andrew Simmons
2004-03-02 20:56 ` matt
2004-03-02 20:57 ` ron minnich
2004-03-02 12:44 ` Bruce Ellis
2004-03-02 7:50 ` lucio
2004-03-02 7:56 ` David Tolpin
2004-03-02 8:12 ` Charles Forsyth
2004-03-02 8:12 ` David Tolpin
2004-03-02 8:45 ` Charles Forsyth
2004-03-02 8:51 ` David Tolpin
2004-03-02 9:06 ` David Presotto
2004-03-02 9:14 ` David Tolpin
2004-03-02 9:26 ` Charles Forsyth
2004-03-02 15:04 ` rog
2004-03-02 15:12 ` David Tolpin
2004-03-02 16:03 ` C H Forsyth
2004-03-02 16:06 ` David Tolpin
2004-03-02 16:24 ` David Tolpin
2004-03-02 16:35 ` C H Forsyth
2004-03-02 17:18 ` andrey mirtchovski
2004-03-02 12:39 ` Bruce Ellis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ba1d5fce00018498c7b91b0d698cbd64@vitanuova.com \
--to=rog@vitanuova.com \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).