- What is a thread?
- What is multithreading?
- What is the difference between a thread and a process?
- Why use multithreading in your applications?
- What is a thread pool?
- During a thread’s lifetime, what states can it have?
- What is a race condition?
Top 13 Multithreading Questions Asked In Interview With Explanation and PDF | Most Important
multithreading interview questions c++
struct MyClass // remember, in C++ a struct is a class that defaults to public. { long _iID; char _strLabel[16]; MyClass(long iID) : _iID(iID) { memset(_strLabel, 0, sizeof _strLabel); } virtual bool doSomething(); }; bool MyClass::doSomething() { printf(“ID = %ld Label = %-*.*s “, _iID, sizeof(_strLabel), sizeof(_strLabel), _strLabel); } /* C example with data member that is a function pointer used to simulate a virtual method. Notice how much more verbose the C example is compared to the C++ example above. */ #include
#include
�strstream is the class that specializes iostream to use a strstreambuf for input and output with arrays of characters in memory. You can create an strstream object by associating the object with a previously allocated array of characters. You can then write output to it, read input from it, and apply other operations to it just as you would to another type of stream.
The static
keyword is useful for extending the lifetime of a particular variable. If you declare a static variable inside a function, the variable remains even after the function call is long gone (the variable is placed in the alterable area of memory). The static
keyword is overloaded. It is also used to declare variables to be private to a certain file only when declared with global variables. static
can also be used with functions, making those functions visible only to the file itself.
When we use %d the compiler internally uses it to access the argument in the stack (argument stack) .Ideally compiler determines the offset of the data variable depending on the format specification string.Now when we write printf(�%d�,a) then compiler firast accesses the top most element in the argument stack of the printf which is %d and dependin on the format string it calculated to offset to the actual data variable in the memory which is to be printed.Now when only %d will be present in the printf then compiler will calculte the correct offset (which will be the offset to access the integer varible) but as the actual data objet is to be printed is not present at that memory location so it will print what ever will be the contents of that memory location.