The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

threads?

When you login to Google Analytics and click on "View Reports", the Dashboard starts loading, and you see the various sections getting filled with content, like "Visitor Overview", "Map Overlay", ... They seem to be updating independently of each other. How is that done? Separate threads?

On a separate note, I hear over and over that threads are hard to get right, and Joel thinks forking is better than using threads, but forking seems like an overkill for say handling GUI code to improve app responsiveness..

So, when should I be using threads then?
threader
Monday, June 09, 2008
 
 
AJAX
uggh
Monday, June 09, 2008
 
 
I don't know AJAX. I am not a web developer. Does that mean it is using threads or not?
threader
Monday, June 09, 2008
 
 
It looks like Firefox creates a new thread for each XMLHttpRequest: http://www.alexyoung.org/articles/show/16/dismantling_browser_ajax_handling
John Topley Send private email
Tuesday, June 10, 2008
 
 
With proper design, threading can be easier than forking.  IPC  in a forking design usually requires more overhead in both compute terms and in code terms.  Though there is more protection from mistakes.  Having worked for company that only used forking and working for a company that mostly uses threading, there is little to no difference in the issues you have to consider when designing for each.
Brian
Tuesday, June 10, 2008
 
 
In my last gig we had a dual-threaded application that was a nightmare. Nightmare to debug, nightmare to update, nightmare just to wrap your head around.

I replaced it with a dual process design that had a net loss of several thousand lines of code, was easier to grasp, considerably easier to debug, and ran measurably quicker. It took me a couple days to prototype and a couple man-weeks to implement whereas the multithreaded approach tool several man months, maybe as much as a man year to implement and it still had confounding bugs.

That's not to say all threaded code is that way. I think this was an extreme example of threads gone bad. Threads have their purpose, but when used unwisely can contribute greatly to the complexity of a particular solution.
Just another voice in the crowd
Tuesday, June 10, 2008
 
 
Threading is easy. Debugging poorly written threading code is not. The key seems to be to writing this code well the 1st time around ;)

If you stick to a simple design you will find your threading code will be quite manageable. Just my 2 cents.
Gili Send private email
Tuesday, June 10, 2008
 
 
Threads are generally used in desktop applications. The topic-starter wants to refresh a part of the page that is visible in the webbrowser.

Correct me if I'm wrong, but aren't we talking about a XmlHttp request (async)? I doubt that the server will have any influence on the number of threads that the browser spawns.
Eddy Vluggen Send private email
Wednesday, June 11, 2008
 
 
Correct me if I'm wrong, but didn't I answer the OP's question a few posts ago? :-S
John Topley Send private email
Wednesday, June 11, 2008
 
 
You did.. As did Ughh..

Once you've got a thread, every problem becomes a nail :)
Eddy Vluggen Send private email
Wednesday, June 11, 2008
 
 
Firefox does (up to some limit) use different threads for your XMLHTTPRequests. Your JavaScript code however will be single-threaded. There are no threading constructs in Javascript that would support thread-safe programming.
HB Send private email
Thursday, June 12, 2008
 
 
The web server is multi-threaded.  And Firefox creates a new thread for each XMLHttpRequest!
Has the question been answered now?
Thursday, June 12, 2008
 
 
#define question

"They seem to be updating independently of each other. How is that done?"
Eddy Vluggen Send private email
Friday, June 13, 2008
 
 
> #define question
>
> "They seem to be updating independently of each other.
> How is that done?"

They get the little rotating circles animation happening and they get populated (seemingly) independent of each other.
threader
Monday, June 16, 2008
 
 
I don't know how it's done on Google Analytics, but generaly in AJAX you'll create new XMLHttpRequest object to update every section of the page.
XMLHttpRequest provides asynchronous interface for retriveing data from web server, so all you have to do is start the request and provide an event handler that will be called after the web request completes.

There is threading involved but it's all done by the web browser. No threading in the page code.
piaskal
Tuesday, June 24, 2008
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz