... continued

We'll cover the following...

Using a Background Thread

The previous solution consisted of manipulating pointers in time, thus avoiding threads altogether. Another solution is to use threads to solve the token bucket filter problem. We instantiate one thread to add a token to the bucket after every one second. The user thread invokes the getToken() method and is granted one if available. We instantiate one thread to add a token to the bucket after every one second. ...