Multithreading and Automatic variable

Below code will explains automatic variable and multi threading.
For below code , for case-1 and case-2 output is different ,

For case-1 output is  0 1 2 3 4
For case-2 output is 5 5 5 5 5
For case-2 it creates 2 parallel threads while for case-1 it is just initial assignment of automatic variable.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s