Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

java - What's a good, efficient way to implement run()? -


should contain loop

while (true) { ... }

i find not efficient consumes cpu much. thread keep on waiting what's best way make wait without consuming cpu?

there many ways efficiently using object.wait , object.notify (see here), or using various higher level java concurrency classes such blocking queues, latches, futures, semaphores or barriers.

===================================================

you correct repeatedly testing condition bad idea; e.g.

    while (!condition) {         // bad idea ... burns cpu cycles.     } 

the following improvement, can still problematic:

    while (!condition) {         thread.sleep(...);  // bad idea     } 

the problem if set sleep interval short, loop gets expensive. if set longer (e.g. second or so), thread can take amount of time respond condition becoming true. net result can reduced throughput , / or sluggish user interfaces.

sometimes loop{test; sleep} approach best available option, unfortunately, if can avoid it, should.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -