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

  • SEARCH
  • Home
  • 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 8650507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:50:23+00:00 2026-06-12T13:50:23+00:00

I have two set of values in my two threads, for example, in my

  • 0

I have two set of values in my two threads, for example, in my 1st thread i have odd numbers and in 2nd thread i have even number, but i want to print values like 1,2,3,4…..how to print the thread values alternatively???

NSThread* myThread = [[NSThread alloc] initWithTarget:self selector:@selector(myThreadMainMethod:) object:nil];

[myThread setThreadPriority:1];
NSThread* myThread2 = [[NSThread alloc] initWithTarget:self selector:@selector(myThreadMainMethod2:) object:nil];

[myThread2 setThreadPriority:1];
[myThread start];  // Actually create the thread

[myThread2 start];  // Actually create the thread

Thanks.

  • 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-12T13:50:24+00:00Added an answer on June 12, 2026 at 1:50 pm

    If you want your threads to do their output ordered (which in your case seems to be a really bad idea) then you’ll have to synchronize them with an event so they signal each other to perform the next step in the sequence.

    This however will loose you all benefit of having threads in the first place. If you want to print an ordered sequence of numbers, just do it on the GUI thread.

    For work that makes sense doing in a threaded environment, you’ll be splitting so that as little as possible of it relies on any other work done by any other thread, so as to achieve real parallelism.

    Doing stuff by threads which requires too much synchronization so the effect is that they essential run serially, is senseless.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two results from a data set. I want to add both results
I have two threads and both the threads do a set of calculations and
I have two threads in my PyGTK app: the main thread which runs the
I have two classes set up as follows: class Point { protected: double coords[3];
I have two list: set lista {5 6} set listb {8 9} and the
I have two tables set up in phpmyadmin- table userid and table data. The
Possible Duplicate: Retrieving the last record in each group I have two tables set
I have a two models set up like this: class User < ActiveRecord::Base #
I've got VS 2010 RC running and have two publish profiles set up in
I have two GitHub-hosted clones set up. One is a readonly clone of the

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.