Q:

the public vs public

When should I put "the" in front of "public" ? 

(The) public threatened the security guy in order to go across the restricted area.

what is the role of "the" here ?
Thanks.

A:

In the case of the example sentence you posted

(the) public threatened the security guy in order to go across the restricted area.

The The is definitely necessary there. 
In that case, you are using public as a noun. So anytime you use public as a noun, it needs the in front of it.
The times you don't need to use the in front of public is when you use public as an adjective.
For example

Public bathrooms are often not clean, smelly, and scary.

In this case, public is an adjective describing what type of bathrooms you are referring to. You may also use the in front of the adjective public, but it is not necessary.
Not sure if the above rules are 100% correct all of the time, but I haven't been able to think of any counter examples to it.

