Is using while loop in Java unsafe? -
i heard loops in java take maximum cpu power run fast possible.
is unsafe use while loops run long time?
i know safe in threads if sleep thread little time.
but fast long-lasting loops not inside sleeping thread-safe?
software
no, not really. long don't cause issues held locks deadlocking other parts of code , have valid stopping conditions user doesn't need kill application should fine. however, if creating new objects , hold references them run out of memory.
hardware:
many programs, including java, have fair share of cpu use , loops. games, other compilers, , office applications can this. in fact, many programs rely on infinite loops(albeit stopping condition can of while(true)
type. heat can generated it's nothing worry about.
Comments
Post a Comment