---
title: "线程循环"
author: "tomgooityeeee"
date: "2012-02-07T14:28:53Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2012-02-07T14:28:53Z"
id: 1396551
url: "https://tomgooityeeee.iteye.com/blog/1396551"
---

@selector(xxxThread)方法以后,在方法中添加

```java

-(void)xxxThread
{
    NSAutoreleasePool* pool = [nsautoreleasepool new];
    NSRunLoop* loop = [nsrunloop currentrunloop];

    NSTimer* timer = [[nstimer alloc] initWithFireDate:nil
                                              interval:yourtime
                                                target:self 
                                              selector:@selector(yourFun:) 
                                              userInfo:nil
                                               repeats:YES];
    [loop addtimer:timer formode:nsdefaultrunloopmode];
    
    while([loop runmode:nsdefaultrunloopmode beforedate:[nsdate distantfuture]]);

    [pool release];
} 
```