Results 1 to 10 of 10
Thread: help with networking and threads
- 05-07-2008, 08:55 AM #1
Member
- Join Date
- May 2008
- Posts
- 15
- Rep Power
- 0
help with networking and threads
is there anyway to make this implementation more efficient?
The implementation is:
There is this method thread that has an infinite loop which waits for connections and accepts it if there's one. The implementation is hungry of CPU usage. is there anyway to slow down the CPU usage? like setting up a timeout for the infinite loop, etc. (i'm not quite sure about the timeout thing)
- 05-07-2008, 09:02 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Normally it can be happened, because of the loop. I can't say more about without having exact idea what your application do.
- 05-07-2008, 09:08 AM #3
Member
- Join Date
- May 2008
- Posts
- 15
- Rep Power
- 0
ahh. i see.
well, we are currently making a customized Server-Client instant messenger. and the server (the one that handles connections) is the one that has the infinite loop waiting for connections. is there anyway to lessen the CPU usage by any other means?
- 05-07-2008, 09:48 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Rather using an infinite loop, can you make a request from the client in specific intervals? In that case, only the requesting time CPU usage is high.
Is that server written in Java?
- 05-07-2008, 09:58 AM #5
Member
- Join Date
- May 2008
- Posts
- 15
- Rep Power
- 0
would having an infinite loop that sleeps at specified intervals achieve the same result that you have described?.. im assuming the cpu usage would lessen when the thread sleeps (timeouts)...
- 05-07-2008, 10:00 AM #6
Member
- Join Date
- May 2008
- Posts
- 15
- Rep Power
- 0
Yes, it is in java
- 05-07-2008, 10:33 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Yep it should be, if the thread sleep CPU usage should be lesser. Didi you use more than one thread, if so how did you handle them?
- 05-07-2008, 10:56 AM #8
Member
- Join Date
- May 2008
- Posts
- 15
- Rep Power
- 0
thanks... i yes i used multiple threads, the threads sleep for a specified timeout time.. ive set the timeout time to around 10 milliseconds... is that okay?
- 05-07-2008, 10:59 AM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I don't think 10 millisecond is enough. Can't you do it at least within 1 second. And also, did you synchronized any of thread.
- 05-21-2008, 05:03 AM #10
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Dear cedf128,
This forum is going on with English. I don't think we can communicate other than in English. So it's better to move with it. If you are not much familiar with English, better to ask some one else of your friend and posting here.
Thanks.
Similar Threads
-
Java networking.
By tim in forum New To JavaReplies: 7Last Post: 07-16-2009, 10:43 PM -
Threads and Timeout in Socket Networking
By byuu in forum Threads and SynchronizationReplies: 2Last Post: 05-27-2008, 09:05 PM -
Java networking programming (II)
By Java Tutorial in forum Java TutorialReplies: 0Last Post: 12-27-2007, 06:19 PM -
Java networking programming (I)
By Java Tutorial in forum Java TutorialReplies: 0Last Post: 12-24-2007, 07:21 PM -
Multithreading + Networking (desperate)
By bluebarca in forum New To JavaReplies: 1Last Post: 11-07-2007, 02:14 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks