AndroidStudio 线程
来源:互联网 发布:可以打电话的软件 编辑:程序博客网 时间:2024/06/10 11:57
package com.example.sofia.testactivityactive;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
public class MainActivity extends AppCompatActivity {
MyThread thread = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//启动线程
thread = new MyThread();
thread.start();
}
//线程处理类 Thread **************************************
public class MyThread extends Thread {
@Override
public void run() {
int iCount = 0;
while( true ){
try {
Thread.sleep(1000);//1秒
iCount++;
Log.e( "Thread Aread", "CurrentThread id:---->" + Thread.currentThread().getId() + Thread.currentThread().getName() + " Times:" + iCount );
} catch (InterruptedException e)
{
e.printStackTrace();
}
}//while
}//run
}//MyThread
}
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
public class MainActivity extends AppCompatActivity {
MyThread thread = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//启动线程
thread = new MyThread();
thread.start();
}
//线程处理类 Thread **************************************
public class MyThread extends Thread {
@Override
public void run() {
int iCount = 0;
while( true ){
try {
Thread.sleep(1000);//1秒
iCount++;
Log.e( "Thread Aread", "CurrentThread id:---->" + Thread.currentThread().getId() + Thread.currentThread().getName() + " Times:" + iCount );
} catch (InterruptedException e)
{
e.printStackTrace();
}
}//while
}//run
}//MyThread
}
阅读全文
0 0
- AndroidStudio 线程
- AndroidStudio 子线程通知主线程Demo
- androidstudio
- AndroidStudio
- AndroidStudio
- AndroidStudio
- AndroidStudio
- AndroidStudio
- androidstudio
- AndroidStudio
- androidstudio
- [AndroidStudio]
- 【AndroidStudio】
- Androidstudio
- 安装AndroidStudio
- 安装AndroidStudio
- 安装AndroidStudio
- androidStudio 安装
- MySQL 5.7 MySQL command line client 使用命令
- 数字图像处理实训报告
- Valgrind快速入门指南
- postgre的数组使用
- 卷积神经网络传播过程中感受野的理解以及feature map size 、receptive field size的计算(代码)
- AndroidStudio 线程
- django-rest-swagger的优化使用
- Android面试总结
- 文本文件(ASCII)的读写
- iOS开发之深复制和浅复制
- ImageEditor库详解—————StickerView详解
- 深入理解事务--事务ACID特性及隔离级别
- Gitlab不更新Activity的解决方案
- Valgrind用户手册