is it necessary to call pthread_join()

Yes if thread is attachable then pthread_join is must otherwise it creates a Zombie thread.

Agree with answers above, just sharing a note from man page of pthread_join.

NOTES

   After a successful call to pthread_join(), the caller is guaranteed that the target thread has terminated.

   Joining with a thread that has previously been joined results in undefined behavior.

   Failure to join with a thread that is joinable (i.e., one that is not detached), produces a "zombie thread".  Avoid doing this, since each zombie thread consumes some  system  resources,  and  when
   enough zombie threads have accumulated, it will no longer be possible to create new threads (or processes).

pthread_join does two things:

  1. Wait for the thread to finish.
  2. Clean up any resources associated with the thread.

If you exit the process without joining, then (2) will be done for you by the OS (although it won't do thread cancellation cleanup, just nuke the thread from orbit), and (1) will not. So whether you need to call pthread_join depends whether you need (1) to happen.

If you don't need the thread to run, then as everyone else is saying you may as well detach it. A detached thread cannot be joined (so you can't wait on its completion), but its resources are freed automatically if it does complete.