Re: lines of code?

From: Chris Smith (cdsmith_at_twu.net)
Date: 12/13/03


Date: Sat, 13 Dec 2003 09:10:33 -0700

goose wrote:
> a few points to consider from the above post:
> a) I should have qualified my statement about multiple
> threads not actually buying you anything ("multiple
> threads dont *always* get you anything more than
> single-threaded", for example).

If that were what you'd said, I'd fully agree.

> b) Micheal never pointed out that there were legitimate
> reasons for using threads. his subsequent posts made it
> very clear that his use of multiple threads was in the
> context of java gui; I'm no java expert, but I am under
> the impression that java is kinda useless if you cannot
> have more than one thread; select() functionality has
> only recently (2 years?) been added to java, no ?

It is correct that Java's APIs and language are designed around the
decision that threads are fundamental, so you're right in that respect.
On the other hand, outside of a GUI application, it's entirely possible
to write single-threaded Java applications today, even if they do I/O.
The fact that it wasn't possible prior to the release of 1.4 several
years ago is not very relevant these days.

The requirement for use of threads in a GUI environment mostly comes
from Java's lacking a way to "poll" for events and process them from
within a programmatic loop elsewhere in code. That polling method, so
well-known in VB, is clearly a broken idea in the first place. I would
not want to see a GUI application written as a single thread (though
such applications get written all the time in Microsoft VB environments,
and they generally prove how destructive the idea really is).

In the end, though, I don't personally think this question of
multithreading being "required" in Java is relevant, anyway. After all,
even if multithreading is forced in a few situations, there are still
important decisions to be made as to where specific tasks should be
solved using multithreading and where they should be solved using other
techniques.

> c) In order for you (or Micheal) to justify the "this is
> nonsense" response to my "does not buy you anything",
> you would have to show that all multi-threaded design
> is superior to single-threaded

I think to most people's understanding of English, that's clearly not
the case. For example, if I said it was nonsense to say that cars don't
do any good, I would not have to prove that I should drive a car to my
mailbox in the morning (or even to work, or to the grocery store) to
justify that statement.

Clearly, you have an aversion to multithreading, and I have an aversion
to unnecessarily implementing something as a state machine. My aversion
to use of state machines all over the place is that they throw away the
advantages of high-level languages; a loop no longer looks like a loop,
but rather like a set of state transitions, which you might recognize as
a loop only if you have or bother to draw a state transition diagram.
Apparently, your aversion to threads comes from the potential for
deadlocks and race conditions. I can only say that I prefer one
disadvantage over the other, because at least when reading a
multithreaded application, I can see what's going on.

-- 
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation


Relevant Pages

  • Re: lines of code?
    ... > a) I should have qualified my statement about multiple ... > context of java gui; I'm no java expert, ... multithreading being "required" in Java is relevant, ... to unnecessarily implementing something as a state machine. ...
    (comp.programming)
  • Re: Multiple Inheritance In Java
    ... > cause multiple objects of Object to exist in the code which could be ... There are other approaches to multiple inheritance that don't use the C++ ... suspect that if Java had been defined to have MI, then the ... Java-like language that only allowed interface names to be ...
    (comp.lang.java.programmer)
  • Re: Java Support question
    ... Unfortunately JAVA isnt covered under LE and hard to enforce. ... multiple versions and decide do we just check the web from time to time ... For WebSphere, they have their own environment variables and point ... For IBM-MAIN subscribe / signoff / archive access instructions, ...
    (bit.listserv.ibm-main)
  • Re: Multiple Inheritance
    ... "Java has multiple inheritance. ... James Gosling writes: ...
    (comp.lang.java.programmer)
  • How to make threads share CPU (almost) equally?
    ... multithreading!!!) ... I tried lowering current thread's priority to MIN_PRIORITY before ... I feel that it is not a proper way of making threads share CPU ... I am using Java 1.5 on Windows XP platform. ...
    (comp.lang.java.programmer)