basically, how do they match up buyers and sellers?
when i want out, how do I know that if i were to sell on my end, someone is definitely going to buy, and vice versa?
The stock exchanges are basically formal versions of something like the FS/trade forum, or a classified ad site like craigs list.
If you look at such a site, there are 2 types of ad:
1. Want to Buy (e.g. Want to buy 10x core i7-2600k - will pay $100 each).
2. For sale (e.g. For sale core i7-2600k - $150)
What this means is that there are 2 prices (the "bid" price - in this example $100; and the "asking" price - in this case $150). Normally when you see a stock price listed on a web site or TV, it is the "mid-price" which is the average of the bid and ask. But the bid/ask prices are more important, as they tell you where the buyers/sellers are.
There are 2 types of buyer:
1. I want one now (They will find the lowest price asked on the available ads, contact the seller and agree the transaction) - this is called a "market" order.
2. The one who wants a better price and is prepared to wait (They will place an ad stating WTB, their maximum price, and wait for a seller to come to them) - this is called a "limit" order.
Similarly, there are 2 types of seller (market and limit).
It's exactly the same for stock - the stock exchange collects buy orders and sell orders - and will automatically match them.
So, if there are 3 sellers of apple stock, so the availabilty is as follows: 1000 AAPL stock available at $200, 1000 available at $201 and 1000 available at $202; then if a buyer comes along and places an order for 3000 stock (@ current market price), he will automatically be matched to those 3 sellers.
The risk with this is that a large buyer might deplete all the sellers. E.g if the buyer wanted 100000 shares (at any price), he might deplete the available sellers, he could potentially end up buying being automatically matched to people at much higher prices e.g. $300. So normally, a buyer will have the opportunity to set a maximum price.
E.g. the buyer might place an order of "buy 100k AAPL with limit of $205". He will be automatically matched up to $205, and any orders that have gone unfilled will be converted into a "WTB" advert @ $205.
Some stocks are very popular, because they are big companies (so there is a metric ****-ton of stock around), and/or because the stock fluctuates wildly on news (so gamblers like quick buy/sell trades) and/or because there are lots of buyers/sellers (because the company has a lot of fans - either as individual people buying stock or money managers looking to make profit for their clients).
So, in the case of a company like AAPL where 10s of millions of shares are traded each day - the comapny will have no difficulty finding sellers.
However, for small companies with not much stock, or where there are very few people trading the stock (e.g. most of the stock is held by long-term investments), buying and selling is more difficult. The market depth (the number of buyers/sellers with active WTB/FS ads at the time) is often very low, and if you place a buy or sell order it may not go through because there is no buyer/seller to be matched with (or if you place a WTB/FS type order, the order may sit there for weeks or months before it gets matched).
To get around this, there are often "market makers". These are traders who will keep a bunch of shares "in stock", and will advertise both WTB and FS. This way, small traders will still be able to buy and sell. However, the market maker will usually give poor buying and selling prices (he's got a boring job, and risky job as he may end up holding a bunch of stock in a dog**** company. So he has to make a profit somehow).