Questions tagged [nsthread]

`NSThread` is part of the Objective-C Foundation Framework and provides developers a way to create and manage threads.

An instance of NSThread controls a thread of execution. Developers can use this class when they would like to perform a series of tasks in its own thread of execution. An example is if the developer wanted to have an Objective-C method run in its own thread of execution.

Threads are useful for long-running tasks that avoid blocking the main thread of the application (where user interface and event-related tasks are handled), as well as dividing a large task into several smaller sub-tasks. This can lead to performance improvements.

In GNUStep, NSThread essentially encapsulates OpenStep threading. Each process starts with a main thread and additonal threads can be created by using NSThread. The GNUStep implementation of OpenStep was designed so that the internals of the base library do not use threading (except in the case of methods that explicitly deal with threads). This makes it possible to write applications without any sort of threading.

References

729 questions
3
votes
2 answers

Best way to implement by multithreading

I'm kind of new to multithreading, and need some advice. I'm using ARC in my code. Problem : I've set up NSTimer in my app to fire every 1 second some method which creates and starts thread like this //Create a new thread mSomeThread = [[NSThread…
deimus
  • 9,565
  • 12
  • 63
  • 107
2
votes
1 answer

Generating images in the background

I am currently building an application that generates images and stores them in an NSMutableArray, which then used in a UINavigation (Cell.imageView.image). I need to be able to handle up to 2000 images without causing lag in my application.…
John Riselvato
  • 12,854
  • 5
  • 62
  • 89
2
votes
1 answer

Table view freezes when sql queries are fired in thread

I have attached a new thread and in that thread I'm firing 5 SQLite queries. Problem is that until execution of all my queries is finished, I'm not able to scroll the table view. It freezes for some seconds. -(void)viewDidAppear:(BOOL)animated { …
ruyamonis346
  • 357
  • 3
  • 15
2
votes
0 answers

Can someone explain to me how scheduling works between a main thread and an NSThread?

For example is it doing something like SCHED_FIFO or SCHED_RR from pthreads? Can the scheduling policy be changed? Can priorities be assigned to the main thread and an NSThread? Ultimately I would like the main thread to run at 30 Hz with a…
Xavier
  • 8,828
  • 13
  • 64
  • 98
2
votes
1 answer

Threading in Spidermonkey

I am trying to enable a threaded debug dump in SpiderMonkey, by editing the jsinterp.cpp file. Basically, the things I am trying to do are as follows: Catch a JSScript before the main loop of Interpret() begins. Open a separate thread. In that…
Anton
  • 153
  • 2
  • 12
2
votes
3 answers

NSOperationQueue and Dispatch Queue as replacement of NSThread performing a repetitive task

I have an application in which I am repetitively calling a method in background. I implemented this by following below steps: created a background thread, called the appropriate method on the created thread, called sleep method on the thread, and…
Devarshi
  • 16,440
  • 13
  • 72
  • 125
2
votes
0 answers

Yield with NSThread?

I have an NSOperationQueue and I want to cancel some operations. Therefore I iterate over the operation and cancel some tasks. At another point in the code which is executed subsequent in the same (UI) thread I check how many operations are in the…
2
votes
1 answer

Run ALAssetLibrary Block on Separate Thread

I am planning to get/add all the photo Library Image URLs into an NSMutableArray on a separate thread without disturbing the execution of program or main thread. I need to do the process on application background while other operations are going…
adrian
  • 4,574
  • 17
  • 68
  • 119
2
votes
2 answers

why do I get "wait_fences: failed to receive reply" for this code?

why do I get "wait_fences: failed to receive reply" for this code? Is it the way I'm using notification to communicate back to the main thread? #import "ViewController.h" @implementation ViewController @synthesize alert; #pragma mark -…
Greg
  • 34,042
  • 79
  • 253
  • 454
2
votes
1 answer

NSOperationQueue vs NSThread Priority -- controlling how much cpu is consumed in NSOperationQueue

I have some textures and sound effects preloading I need to do asynchronously to create a smooth user experience in an iOS game I am developing. I am trying to decide between NSOperationQueue and NSThread to load these game resources during…
mattorb
  • 3,075
  • 3
  • 22
  • 16
2
votes
2 answers

Help with crash log

My app is crashing on Lion when it awakes from sleep. The problem seems to be with a background thread that is looking for weather info. I'm not sure but I think the crash log is telling me that the autorelease pool is popping objects that are no…
the Reverend
  • 12,305
  • 10
  • 66
  • 121
2
votes
3 answers

Using an application-lifetime-thread other than the main thread

I've a multi-threading application in which each thread has to do some job, but at a certain point some code needs to be executed serially (like writing into sqlite3 database), so I'm calling that code to be performed on main thread using: [self…
Mousa
  • 2,926
  • 1
  • 27
  • 35
2
votes
2 answers

Delegate callback from other NSThread

I have object with .delegate property which i manipulate in method 'doJob'. I assign this property with 'self' and my function is being called when this object finishes his job. Till now everything is fine. Now i want to manipulate this object in a…
Misha
  • 5,260
  • 6
  • 35
  • 63
2
votes
1 answer

Getting location in iOS background

I want to get my location in background every X mins, I'm using a thread which is running well with NSLog, it prints a string. However, it seems that it's not working when I call my locationManager. This is my code: -…
Ibaivi
  • 51
  • 4
2
votes
1 answer

Improper behavior of NSTimer on separate thread

I am trying to schedule NSTimer on a separate thread and this is how i am doing it. -(void) startSpinner { #ifdef DEBUG_MODE NSLog(@"Starting Spinner..."); #endif self.spinnerThread = [[[NSThread alloc] initWithTarget:self…
user745098