Cash flows can be positive or negative at any point in time, however. To compute payback, find where the cumulative cash flow becomes positive. Both projects recover the initial investment in the third year. For independent projects the rule is to accept all projects which have a payback less than some predetermined number. For mutually exclusive projects, the rule is to accept the project with the shortest payback.
Some companies use payback however.
The time value of money problem can be solved by using discounted payback. A couple of comments about discounted payback. Thus, some projects which do not satisfy an arbitrary payback cutoff but have positive NPV's may be rejected. In summary, it does not have any real economic meaning. For independent projects the firm should accept all projects for which IRR exceeds the cost of capital.