File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Thread Handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Thread Handling" Watch "Thread Handling" New topic

Thread Handling

John Chien
Ranch Hand

Joined: Feb 06, 2003
Posts: 105
Hello, I am new to this discussion group. I found that there are many good discussion about SCJD exam. It helps me a lot in term of doing the design.
However, I did not see any discussion about multi-thread handling. How should we handle the multi-threading for the exam ? Should we create a thread pool in server side ? Where can I find the best reference about creating thread pool ? I found several books talk about it, all of them looks very complicated.

SCJP, SCJD, SCWCD, SCBCD<br />IBM Certified Specialist (158)<br />Oracle9i PL/SQL Developer Certified Associate
Matt Ghiold
Ranch Hand

Joined: Feb 24, 2002
Posts: 213
If you choose RMI for a solution, this is all handled for you. Natively RMI has a thread pool, socket reuse and is multi-threaded. Hope this helps.
If you choose sockets, you will have to right your own.

-Matt<br /> SCJP2<br /> SCJD
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
If you use sockets, remember the "favour clarity over performance" requirement and don't use a thread pool. IMHO you'd simply create threads as required.
- Peter
Pete Harris
Ranch Hand

Joined: Feb 05, 2003
Posts: 39
I seem to be the only person using serialization here and I agree with Peter - Don't use a thread pool. The simple answer is to have one thread per connected clientas this endures that there are no thread management issues.
John Chien
Ranch Hand

Joined: Feb 06, 2003
Posts: 105
I am going to use RMI. I have already written a thread pool by following a book. It is nice to know that RMI has already handle the thread pool for me. I will remove the code that I wrote. (It has already be tested without using RMI). Thanks.
Max Habibi
town drunk
( and author)

Joined: Jun 27, 2002
Posts: 4118
Hi John,
It's important to know that, even using RMI, you can still run into threading issues. A Thread pool make sure that you're not wasting threads, but it doesn't keep two threads from attempting to modify the same resource. That's where your locking code comes in.
M, author
The Sun Certified Java Developer Exam with J2SE 1.4

Java Regular Expressions
I agree. Here's the link:
subject: Thread Handling
jQuery in Action, 3rd edition