File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Threads and Synchronization and the fly likes Defining threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Defining threads" Watch "Defining threads" New topic

Defining threads

Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191

I am new to threads and was wondering:

My program is running as a single thread i.e. there is no thread defined - it just runs. Now, I need to create a new thread which I have done succesfully ( i think ). What I would like to know is that if my main program requires a new thread to run as above, so that two things can run concurrently, should I define what was previsouly the main program as a thread as well - or is just defining the new thread i need enough?



Moosey knows best
Henry Wong

Joined: Sep 28, 2004
Posts: 20352

The main() method is called using the main thread -- which is already a thread.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191
I see. Thanks Henry.
Maris Orbidans
Ranch Hand

Joined: Mar 08, 2004
Posts: 149
a new thread is enough
I agree. Here's the link:
subject: Defining threads
It's not a secret anymore!