When the first random lockup occurs, it is usually a good idea to make a quick note of the date and the last thing that you changed on your computer - hardware or software. Most times, that change will hold the key to the lockup. Also making a note of what programs are running in the taskbar at the time of the lockup is a good idea. Some programs just won't work and play well with others. Another thing to check is the free space left on the primary hard drive.
Nothing makes a computer behave more strangely than a hard drive that is full.
Obviously, if the same program is always running when a lockup occurs, the program is suspect. On the other hand, if it happens with different programs running, it could be hardware related or it could have something to do with the operating system. Loading the latest service packs for your version of Windows and getting the latest upgrades for the programs you are running can sometimes fix the problem as well. A hard drive that is always full can drive you nuts and it can also cause some of the speed and random lockup problems discussed above. Hard drives are very cheap now, and it's not too hard to put one in.