By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,435 Members | 2,033 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,435 IT Pros & Developers. It's quick & easy.

how to run 2 thread with different code

P: n/a
i'm just learning java now, so this might be obvious, but not to me.

my app needs to do two things:
(1) connect to and fetch a list of tasks for a user from a web service
(2) connect to mapquest and get driving instructions

both connections should run under a separate thread, but from what i've
read, threads can only implement a single run() method. so, how do i get
thread 1 to connect to one web service and thread 2 to connect to the other
if they share the same run method?

tks
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
anybody?
"Dica" <ge*****@hotmail.com> wrote in message
news:1J********************@rogers.com...
i'm just learning java now, so this might be obvious, but not to me.

my app needs to do two things:
(1) connect to and fetch a list of tasks for a user from a web service
(2) connect to mapquest and get driving instructions

both connections should run under a separate thread, but from what i've
read, threads can only implement a single run() method. so, how do i get
thread 1 to connect to one web service and thread 2 to connect to the other if they share the same run method?

tks

Jul 18 '05 #2

P: n/a
Dica wrote:
i'm just learning java now, so this might be obvious, but not to me.

my app needs to do two things:
(1) connect to and fetch a list of tasks for a user from a web service
(2) connect to mapquest and get driving instructions

both connections should run under a separate thread, but from what i've
read, threads can only implement a single run() method. so, how do i get
thread 1 to connect to one web service and thread 2 to connect to the other
if they share the same run method?


A single thread may implement only one run method (although this is not
precise language). However, different threads may admit different run
methods.

This is basic threading API stuff; you need to start with a good book or
tutorial on the basics. Don't try to cut-n-paste or hack together
thread code, you will regret it.

HTH,
Ray

--
XML is the programmer's duct tape.
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.