Multi-threading gives a program the ability to perform several tasks concurrently. This allows the program to perform lengthy operations in separate threads, enabling the user to continue to interact with the program while these operations take place.
MT-NewsWatcher uses Apple's Thread Manager to perform multiple tasks simultaneously, so that you can get article headers in one window while reading messages from another group at the same time.
New threads are spawned for the following operations:
- Checking for new articles
- Fetching articles (including saving them to files)
- Fetching group headers
- Opening article references
- Extracting binaries
- Getting news server information
- Sending messages
- Batch-printing articles
- Relying to several articles
- Resorting and rethreading subject lists
All these operations add a task to the "Tasks" window:
To cancel a task, you can click to select it, then click on the "Cancel" button. You can cancel a task with the keyboard by typing Command-period; the task that gets cancelled is the one marked with the Command-period symbol (e.g. the lower task in the image).
When fetching articles for a subject window, or fetching the next article when you already have an article window in front, you can also use Command-period to cancel fetching the article.
Extracting binaries in multiple threads is one of MT-NewsWatcher's most useful features. The easiest way to do this is to select the articles you wish to extract in a subject window (using the command key for discontiguous selection if necessary), they using the Command-B keyboard shortcut to extract the binaries. This spawns a single thread, in which the selected items are sequentially extracted:
The articles to be extracted are marked with a diamond character, which changes to the check mark when extraction is complete. The progress bar shows the status of the complete download operation. If the operation is cancelled, those articles which were marked with a diamond are marked again as unread.
Having started one extraction thread like this, you can deselect the previous set of articles, select another bunch and do Command-B again to spawn another thread.
MT-NewsWatcher imposes an upper limit of 20 threads, and 6 network connections. To understand how thread and connections interact, you should read this section.
The 20-thread limit determines the number of threads that are pre-allocated
when MT-NewsWatcher starts up; this translates into an upper limit of 20 concurrent
operations (each of which normally shows a status window). If you already have
20 operations going and attempt to start another one (by opening another
group, for example) you will get an error message saying that no free threads
are available. This limit of 20 threads can be adjusted by editing the '
resource with ResEdit, though increasing it will increase the amount of memory used.
You can control the maximum number of connections to a news server that MT-NewsWatcher will open in the 'News Servers' dialog. This cannot be increased above 6. Normally, you set this at 4, to avoid placing undue load on your news server. If your server imposes an upper limit on the number of connections, then set this value to that upper limit, which ensures that MT-Newswatcher will never attempt to open more than this number of connections.
Every time you perform an operation that spawns a new thread, the program checks to see if you are below the limit on the number of connections. If so, a new connection is opened (or an idle one is reused), and the thread proceeds. If you already have the maximum number of connections active, the thread simply waits until there is a connection spare before it proceeds.
Thus, if you open 20 groups at the same time, 20 threads are spawned, of which the first 4 open news server connections and start to fetch headers. The rest simply stay in the 'Waiting for a free connection' state. When one of the active threads completes, its connection is then reused by a waiting thread which can now start to fetch headers from the server.
Having the ability to open multiple threads does not automatically mean that everything will become instantaneous; indeed, improper use of threads may make some operations slower, particularly if you are on a slow network connection. Selecting all your subscribed groups, and hitting 'Return' to open them all up is not a good idea. Things work most efficiently when you have one or two threads which are downloading data, while perhaps reading articles in an open subject window. More threads than this may impact on the responsiveness of the program and, if you are on a modem connection, won't speed things up any. The current threading implementation in MT-NewsWatcher makes no attempt to queue up user commands to be executed as the resources become available; threads are spawned when the user requests them. This may change in future implementations.
Threading does incur some overhead, in terms of memory in particular, but these are far outweighed by the benefits of not spending hours staring at a rotating cursor while your newsreader gets article headers from the server. The memory overhead is not excessive (somewhere in the region of 24 Kb per thread).
For a couple of functions, MT-NewsWatcher uses a background task which does a little bit of processing at a time when it detects that you are not doing other things. Such tasks are used to expire old articles in the Article Index, and old entries in the database that is used to store information about which articles you have read. Both these operations can cause some disk activity, so don't be alarmed if you hear some when MT-NewsWatcher is apparently sitting doing nothing.
- Table of Contents
- Advanced features
- The Interface