Shweta
--
You received this message because you are subscribed to the Google Groups "Bangalore Open Java Users Group- BOJUG" group.
To post to this group, send email to bo...@googlegroups.com.
To unsubscribe from this group, send email to bojug+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/bojug?hl=en.
Shweta
Streams usually have a non blocking predicate to find out if stream has data, you can use a while loop around the predicate as condition ANDed with timeout condition. Or you can unused the blocking call in a different thread and take action based on timeout in another thread. The timeout thread can check buffer value for emptiness that the blocking thread is supposed to populate should user key-in something.
Oh my! You're really burning the CPU cycles. Add a Thread.sleep(100) to the outer loop--doubtful that the user will notice.Also, if you are going to poll, you don't need another thread. Calculate the timeout value before entering the outer loop, do the check in the outer while for timeout and update the value with each character read.Gosh, I think it has been about 20 years since I've written code like this!Bill
On Tue, Apr 10, 2012 at 5:57 PM, Yaswanth Ravella <ma...@yaswanth.org> wrote:
I mean, it was OK when people were using DOS as an operating systems. But for Linux and Windows users, no way!On Fri, Apr 13, 2012 at 11:36 AM, William la Forge <lafo...@gmail.com> wrote:
Truth. I just hate using software which hogs the machine with a poll loop. Without the sleep, the application is pretty hostile. --b
Truth. I just hate using software which hogs the machine with a poll loop. Without the sleep, the application is pretty hostile. --b
A JVM on a 32 bit OS can occupy a max of 4 GB RAM (theoretically)
On Apr 15, 2012 9:30 PM, "shweta sharma" <shwe...@gmail.com> wrote:Oh !! is it .....wasn't aware about it .
>> A poll loop without a sleep drains your battery excessively and needlessly,
I read that JVM on 32 bit OS occupies at most 2GB .So in worst case a loop can occupy more memory .
How memory is related to power ?
Thanks
Shweta
On Fri, Apr 13, 2012 at 11:41 AM, William la Forge <lafo...@gmail.com> wrote:
>
> There are also ...
--
Not memory, CPU time hog.
But even that is usually not as bad when you have your kernel running a good process scheduler like CFQ in Linux. But sleep makes your program a good userland citizen for less capable OSes. So its good anyway.
--