Re: The simplest way to download a file from http resource that need
authentication
Andreas Leitgeb wrote:
Lew <lew@lewscanon.com> wrote:
Andrea Francia wrote:
Lew wrote:
Andrea Francia wrote:
Authenticator.setDefault() method which is a static method and therefore
not usable in a threaded enviroment.
Static methods can be used in a multi-threaded program.
Lew, sometimes I really wonder if you aren't actually trolling.
Non-static methods can have race conditions, too. Deadlocks, even. There's
no difference from static methods in that regard. Why do you single out
static methods?
It's perhaps not so much the static methods, but rather the static data
that gets set by the former, and which is supposed to be specific
to each thread. Having to synchronize the whole "set user-data and
fetch file"-block almost voids the whole point of parallelizing the task.
Perhaps it suffices to synchronize setting the user and opening the
connection, and leave the actual transfer unsynchronized, but I don't
feel very comfortable that way.
Andrea felt the same way, but I really don't understand the reaction. It is
true that static methods can be used in a multi-threaded program. The
statement to the contrary was not correct, and it is normal in Usenet to set
the record straight.
There are any number of programs that find it useful or convenient to share
static data and methods among threads. I stuck to the technical facts, and
provided correct information that should be useful to the OP and everyone else
reading. So why the hostility?
--
Lew