Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8816781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:41:49+00:00 2026-06-14T04:41:49+00:00

I am fairly new with Java Threads , I normally use C with it

  • 0

I am fairly new with Java Threads, I normally use C with it comes to parallelization. To parallelize algorithm that has the same pattern as the one it follows:

void traverse(node* p)
{
    if (p->left)
        #pragma omp task // p is firstprivate by default
        traverse(p->left);
    if (p->right)
        #pragma omp task // p is firstprivate by default
        traverse(p->right);
}

I would use the task directive of openMP, for example.

Task Description

When a thread encounters a task construct, a task is generated from
the code for the associated structured block. The encountering thread
may immediately execute the task, or defer its execution. In the
latter case, any thread in the team may be assigned the task.
Completion of the task can be guaranteed using task synchronization
constructs. A task construct may be nested inside an outer task, but
the task region of the inner task is not a part of the task region of
the outer task.

My question is:

How I could implement this same idea (task) with Java Threads?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:41:51+00:00Added an answer on June 14, 2026 at 4:41 am

    The pragmas of OpenMP do make parallelization a little easier.

    In Java, you would first need to create a class that implements Runnable.
    – example: public Class Traverse implements Runnable

    You then just neew to create the class and call ‘run’ to start the thread.

    private void traverse(node p) 
    {
       Traverse t = null;
    
        if (p.left)
           t = new Traverse(p.left);
        if (p->right)
           t = new Traverse(p.right)
    
        t.run();   // start thread. this call will not wait for run to finishes
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm fairly new to Java and am writing an app that needs an XML
I'm fairly new to Java and have a doubt that needs to be cleared.
I'm fairly new to Rational Functional Tester (Java) but I have one large blank.
I'm fairly new to Java (and stackoverflow for that matter) so I'll try my
I am fairly new to java and now I want to use java to
I'm fairly new to java and looking for an interface that simply guarantees that
I'm fairly new to Java and Android programming in general but I would like
I'm still fairly new to Java, but I'm fairly sure this shouldn't happen. There's
I am fairly new to Java, and recently I was reading some material about
I am fairly new to Java so am looking for a good way of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.