Can a function run independently inside a main app? [OpenMP]


Say we have a function that does not interfere with other data and runs independently. However, I heard a method to do it is to make the whole app in to a section and that alone a section. Can it be done instead with the main app spawning it into a thread and ensuring that the main app will not wait for it to end?

e.g. pseudo code:

int main (void) { <do stuff on thread 0> <do stuff on thread 0> <spawn independent function on thread 1 with no waiting> <do stuff on thread 0> <do stuff on thread 0> }

EDIT: Can it be done with another philosophy completely? (no OpenMP)


This isn't OpenMP's prime goal: it was built for parallel processing, not concurrent programming. Check your local thread library and look for something called "daemon threads", "detached threads" or similar.


If you are referring to detached threads, then the answer is yes. The thread runs, then exits without having to be waited for. You lose the ability to get a return status from the thread.

Larsmans post points out why you probably do not want to use threading


  • Find cumsum of subarrays split by indices for numpy array efficiently
  • Brace expansion with range in fish shell
  • Ember.js - Can the root url link to two routes, one for authenticated users and one for guests?
  • Forms in MasterPage and Views
  • How to replace TouchesBegan with UIGestureRecognizer
  • How to send control C to Mac Terminal using python?
  • SQL Server re-calculate or not?
  • PHP get selected value of select form
  • What's the name of this finding square root algorithm?
  • Possible to “watch” both HAML and SASS at the same time?
  • How to specify input and output paths from cmd.exe for a PowerShell script?
  • Cast between interfaces whose interface signatures are same
  • Alternative To body {overflow:scroll;} That Will Prevent Page Jostling/Wriggling?
  • Setting up SourceTree to merge unity3d scenes with UnityYAMLMerge
  • Database structure design with variable amounts of fields
  • QLineEdit password safety
  • Fetching methods from BroadcastReceiver to update UI
  • Symfony2: How to get request parameter
  • Rearranging Cells in UITableView Bug & Saving Changes
  • GridView Sorting works once only
  • WPF Applying a trigger on binding failure
  • Benchmarking RAM performance - UWP and C#
  • Acquiring multiple attributes from .xml file in c#
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • How can I remove ASP.NET Designer.cs files?
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • Busy indicator not showing up in wpf window [duplicate]
  • Sorting a 2D array using the second column C++
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • failed to connect to specific WiFi in android programmatically
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal
  • How can I use threading to 'tick' a timer to be accessed by other threads?