Forums Register Login

problem with Threads and System resource usage , need advice on using Thread or not..

+Pie Number of slices to send: Send
Hi
Thank you for reading my post.
I have a problem with threads and timers ,
my problem is :
I send some data over a port to some device , now i should wait until the device send me an acknoledge
after device send the ack i will go with sendingnext data.
Now , after i send first data , i execute a thread
inside that thread , i have a while loop
inside the loop i read the port until the ACK port values go to true,
then i exit the loop and exit the thread too.

this solution works , but it has some other problems
1-in this case java process will eat all CPU cycles
2-my application will GUI does not response good enought

How i can solve this problem ?

Thanks


here is the code that i create the thread and execute it

+Pie Number of slices to send: Send
You could put a "Thread.sleep()" call into that while loop, so it wouldn't poll the parallel port quite so often. I bet that even sleeping for 5 milliseconds would make a big difference.
+Pie Number of slices to send: Send
A Thread.yield() might also work.

Moving to Threads and Synchronization...
pie. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 609 times.
Similar Threads
Can't write collection back to disk
problem with Threads and System resource usage , need advice on using Thread or not..
Integer cannot be cast to client
Threads in jsp programs
Threads and Sockets
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 20:53:00.