Developer's notes
4 subscribers
2 photos
1 video
16 links
Developer's notes: memories about projects, tasks, and advice to the beginners
Download Telegram
Threads and interviews

As I mentioned above interviews in IT are weird and full of cringe. In case you're a software developer and want to get a decent income interviews are a "necessary evil", bearing in mind that many companies have several interview sections - highly likely that you'll see tens of them during several years in the industry.

Today I want to bring up memories of my interviews with a quite famous company that altered its name several times. The plot of that wasn't particularly unusual: an online meeting with HR, a test task, a C++ question section, and the final meeting with a department manager. Well, the test task part is unusual. In general, I wouldn't advise anyone to accept this part as long as it isn't paid or you're not just curious about that. I succeded in all the sections except the final one - guess they just found someone ready to get a smaller salary. I have neither negative nor positive emotions with that. Because interviews aren't covered with NDA nothing prevents me from publishing all the details: without further delay the test task description:

Write a console C++ program with two threads, where the first thread prints '1' and the second one prints '2', and, the most important condition, a one always precedes a two, so the output should be '12121212...', the program works endlessly. Use only the standard library (std).


Below you can find a naive version of it without any synhronizaation at all, the solution along with a detailed description will be published later.

#include <iostream>
#include <thread>

using namespace std;

int main()
{

auto firstRoutine = [](){
while (true){
cout << '1';
}
};

auto secondRoutine = [](){

while (true){
cout << '2';
}
};

thread th1{firstRoutine};
thread th2{secondRoutine};


th1.join();
th2.join();

return 0;
}


#job #C++ #interview #today #memories #c_plus_plus