• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Thread Handling

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
town drunk
( and author)
Posts: 4118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
HTH,
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
 
We don't have time for this. We've gotta save the moon! Or check this out:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic