# Discussion Section for Feb 26: Threads!

## In Discussion Section

In ds5, you will build a program a test if a number is prime. The simplist way to test for a prime number, `num`, is:

- create a set of all the numbers between
`2` and `num - 1`
- divide
`num` by each number in the set one-by-one, checking if the remainder of any of the divisions is 0
*(There are far more optimal ways of doing this... but we won't worry about that here.)*

To speed up this process, you should divide the set into `t` equal-sized sets. In this MiniMP, you should launch `t` threads
that each test the if a canidate number is prime for a certain sub-set of the set established above.

We have provided example code to help you get started and your discussion section leader will help you with the rest! In this MiniMP, you should see:

- how to create a thread
- how to join a thread
- how to pass a data structure into a thread
- how to return a data structure from a thread

## Compiling and Running

To compile and run your shell, run the following commands from a Terminal on a Linux machine:

$ make

$ ./ptest <prime canidate> <threads>

$ ./ptest 1234567 1

$ ./ptest 1234567 6