Documentation Home

If you're using the Microsoft compiler, then you must add the just::thread include and library directories to your compiler search paths, as described in the readme. By default, the include directory is C:\Program Files\JustSoftwareSolutions\JustThread\include and the library directory is C:\Program Files\JustSoftwareSolutions\JustThread\lib

Once you've done that, using the library is as simple as including the relevant headers and using the functions and classes defined there. Any just::thread headers are included then the appropriate library files are automatically linked in too.

For gcc on Linux, the headers are installed in /usr/include/justthread and the library is installed in /usr/lib. To use the just::thread library, you must specify the correct include path, and the library must be named explicitly when linking. By default it will link against the shared library; if you link against the static library (e.g. with -static command line option) then you must also specify -lrt for timing support. Also, it is important to specify the -pthread option to enable multi-threading support from the compiler. Finally, you may well require the additional library for atomic operations [-latomic], which must be at the end of the link line:

g++ -pthread -std=c++11 -I/usr/include/justthread \
sample.cpp -o sample -ljustthread -latomic

The library requires the -std=c++11 option to enable the gcc C++11 support.

Checking it's all working

To confirm that the just::thread library is correctly installed on your system compile and run the following program:

#include <jss/joining_thread.hpp>
#include <mutex>
#include <iostream>

std::mutex io_mutex;

void greeting(const char* message)
    jss::lock_guard<std::mutex> lk(io_mutex);

int main()
    jss::joining_thread t(
        greeting,"Hello from another thread");
    greeting("Hello from the main thread");
    return 0;

The output should be either

Hello from the main thread
Hello from another thread


Hello from another thread
Hello from the main thread

See Also