- 浏览: 194534 次
- 性别:
- 来自: 上海
-
文章分类
最新评论
Making a Thread
A thread in Java begins as an instance of java.lang.Thread. For the exam, you’ll need to know, at a minimum, the following methods:
start()
yield()
sleep()
run()
You can define and instantiate a thread in one of two ways:
■ Extend the java.lang.Thread class
■ Implement the Runnable interface
方法一:Extending java.lang.Thread
The simplest way to define code to run in a separate thread is to
■ Extend the Thread class.
■ Override the run() method.
下面的例子示例了通过此方法实现的一个thread:
方法二:Implementing java.lang.Runnable
通过实现java.lang.Runnable接口,亦可以定义一个thread,示例如下:
注意:因为是implements一个interface,因此你必须实现其public void run();方法(Runnable接口只有这一个方法)
对应于Define a thread的两种方法,Instantiating a thread也分别有两种方法:
方法一
如果你的thread是通过extends java.lang.Thread的方法获得,那么实例化一个Thread就非常简单:
MyThread t = new MyThread(); //这里的MyThread extends Thread的class
方法二
如果你的thread是通过implements Runnable接口的方法获得,那么实例化一个thread就稍微复杂一些,分为两个步骤:
1.MyRunnable r = new MyRunnable(); //这里的MyRunnable是implements Runnable的class
2.Thread t = new Thread(r); //将你的Runnable class传递给一个java.lang.Thread class
//因为只有java.lang.Thread才有用来启动线程的start()
注意:你可以将一个Runnable传递给多个Thread实例,例如:
上例中:三个Thread运行的任务是独立(三个Thread各自的call stack)且相同的(任务内容是一样的)。
你必须知道Thread的其它形式的构造函数
■ Thread()
■ Thread(Runnable target)
■ Thread(Runnable target, String name)
■ Thread(String name)
■ Thread(ThreadGroup group, Runnable target)
■ Thread(ThreadGroup group, Runnable target, String name)
■ Thread(ThreadGroup group, String name)
Thread的几个有用的方法:
1. public static Thread currentThread() :Returns a reference to the currently executing thread object.
2. public final void setName(String name):Changes the name of this thread to be equal to the argument name.
3. public final String getName():Returns this thread's name.
Methods from the java.lang.Thread Class Some of the methods that can help us influence thread scheduling are as follows:
Note that both sleep() and join() have overloaded versions not shown here.
Methods from the java.lang.Object Class Every class in Java inherits the following three thread-related methods:
The wait() method has three overloaded versions (including the one listed here).
Thread States
A thread can be only in one of five states
■ New This is the state the thread is in after the Thread instance has been instantiated, but the start() method has not been invoked on the thread. It is a live Thread object, but not yet a thread of execution. At this point, the thread is considered not alive. 线程实例(java.lang.thread或者其subclass)对象被创建,但是其start()方法还没有被调用。此时线程还不是活动的(alive).
■ Runnable This is the state a thread is in when it’s eligible to run, but the scheduler has not selected it to be the running thread. A thread first enters the runnable state when the start() method is invoked, but a thread can also return to the runnable state after either running or coming back from a blocked, waiting, or sleeping state. When the thread is in the runnable state, it is considered alive. 此时线程已经满足了所有运行所需的条件,只等到thread scheduler选中它就可以运行了。线程第一次进入Runnable状态的标志是,该线程的start()方法被调用。但是这并不是线程进入Runnable状态的唯一方法,处于Running状态和Blocking状态的线程也可以返回到Runnable状态。此时线程是活动的(alive).
■ Waiting/blocked/sleeping OK, so this is really three states combined into one, but they all have one thing in common: the thread is still alive, but is currently not eligible to run. In other words, it is not runnable, but it might return to a runnable state later if a particular event occurs. 1. A thread may be blocked waiting for a resource (like I/O or an object’s lock), in which case the event that sends it back to runnable is the availability of the resource—for example, if data comes in through the input stream the thread code is reading from, or if the object’s lock suddenly becomes available. 2. A thread may be sleeping because the thread’s run code tells it to sleep for some period of time, in which case the event that sends it back to runnable is that it wakes up because its sleep time has expired. 3.Or the thread may be waiting, because the thread’s run code causes it to wait, in which case the event that sends it back to runnable is that another thread sends a notification that it may no longer be necessary for the thread to wait. The important point is that one thread does not tell another thread to block. 也就是说,导致线程Blocking/Sleeping/Waiting的原因都是线程自身代码运行中遇到的,而其它的Thread并不能够通知/告诉/要求当前运行的线程被Block。There is a method, suspend(), in the Thread class, that lets one thread tell another to suspend, but the suspend() method has been deprecated and won’t be on the exam (nor will its counterpart resume()). There is also a stop() method, but it too has been deprecated and we won’t even go there. Both suspend() and stop() turned out to be very dangerous, so you shouldn’t use them and again, because they’re deprecated, they won’t appear on the exam. Don’t study ‘em, don’t use ‘em. Note also that a thread in a blocked state is still considered to be alive. 值得注意的是,处于Blocking状态的thread仍然是活动的(alive).
■ Dead A thread is considered dead when its run() method completes. It may still be a viable Thread object, but it is no longer a separate thread of execution. Once a thread is dead, it can never be brought back to life! (The whole “I see dead threads” thing.) If you invoke start() on a dead Thread instance, you’ll get a runtime (not compiler) exception. And it probably doesn’t take a rocket scientist to tell you that if a thread is dead, it is no longer considered to be alive.
Thread Priorities and Yield
要知道,不同的JVM实现的线程调度机制不同,有的实行优先级抢占策略,有的实行时间片轮转策略。
通常每个thread都有自己的优先级—priority。一般priority用1到10的数字来表示。
注意:Thread类有以下关于线程priority的static final常量:
public static final int MAX_PRIORITY
The maximum priority that a thread can have.
public static final int MIN_PRIORITY
The minimum priority that a thread can have.
public static final int NORM_PRIORITY
The default priority that is assigned to a thread.
Setting a Thread’s Priority
A thread gets a default priority that is the priority of the thread of execution that creates it.
默认地,一个线程的优先级是和创建它的线程相同的。例如:
the thread referenced by t 和 the main thread具有相同的优先级, since the main thread is executing the code that creates the MyThread instance.
当然你也可以通过Thread实例的public final void setPriority(int newPriority)方法来为一个线程设定优先级。例如:
The default priority is 5
关于yield()方法
也就是说,Thread的yield()方法的作用就是让当前线程暂时停止执行,返回到Runnable状态。以便其它的与之具有相同优先级的处于Runnable状态的线程可以获得调度。
但是这一原则性的策略的执行并不会得到JVM的保证。因为,yield()虽然可以保证使得当前正在执行的线程进入Runnable状态,但是并不会保证进入Runnable的该线程不会被thread scheduler再次选中,重新进入Running状态。因为,被yield()方法放进Runnable Pool的该进程会和Runnable Pool中具有相同优先级的进程一样被thread scheduler来考量
The Join() Method
1.public final void join() throws InterruptedException
Waits for this thread to die
2.public final void join(long millis) throws InterruptedException
Waits at most millis milliseconds for this thread to die. A timeout of 0 means to wait forever.
3.public final void join(long millis,int nanos) throws InterruptedException
Waits at most millis milliseconds plus nanos nanoseconds for this thread to die
Synchronizing Code
Write code using synchronized wait, notify, and notifyAll to protect against concurrent access problems and to communicate between threads.
So how do you protect the data? You must do two things:
■ Mark the variables private
■ Synchronize the code that modifies the variables
关于lock和synchronized我们应该记住下面的要点:
■ Only methods can be synchronized, not variables.
只有method可以被synchronized,变量不可以
■ Each object has just one lock.
每个对象只有一个机锁
■ Not all methods in a class must be synchronized. A class can have both synchronized and nonsynchronized methods.
一个class中并非所有的method都必须是synchronized的。一个class可以有synchronized方法,也可以有nonsynchronized方法
■ If two methods are synchronized in a class, only one thread can be accessing one of the two methods. In other words, once a thread acquires the lock on an object, no other thread can enter any of the synchronized methods in that class (for that object).
机锁具有独占性,一旦被一个Thread获得,其他的thread就不能够再拥有。
■ If a class has both synchronized and nonsynchronized methods, multiple threads can still access the nonsynchronized methods of the class! If you have methods that don’t access the data you’re trying to protect, then you don’t need to mark them as synchronized. Synchronization is a performance hit, so you don’t want to use it without a good reason.
Nonsynchronized方法并不会导致对象的lock被激活。但是过多的使用synchronized method会影响性能,所以要慎用。
■ If a thread goes to sleep, it takes its locks with it.
一个线程进入Sleeping状态,他不会释放他所拥有的其它对象的lock
■ A thread can acquire more than one lock.
一个线程可以同时获得多个对象的机锁(lock)
常见的几个Methods小结:
java.lang.Runnable(inerface):
1.public void run()
java.lang.Thread:
java.lang.Thread implements java.lang.Runnable
1.public void start()
2.public void run() from java.lang.Runnable
3.sleep() throws InterruptedException
public static void sleep(long millis) throws InterruptedException
public static void sleep(long millis,int nanos) throws InterruptedException
4. public static void yield()
5. join() throws InterruputedException
public final void join() throws InterruptedException
public final void join(long millis) throws InterruptedException
public final void join(long millis,int nanos) throws InterruptedException
java.lang.Object
1. Wait() throws InterruptedException,必须在synchronized code中,否则掷出异常IllegalMonitorStateException说明必须拥有lock,注意此异常不需捕捉
public final void wait() throws InterruptedException
public final void wait(long timeout) throws InterruptedException
public final void wait(long timeout,int nanos) throws InterruptedException
2. notify(),否则掷出异常IllegalMonitorStateException说明必须拥有lock,注意此异常不需捕捉
public final void notify()
3. notifyAll(),否则掷出异常IllegalMonitorStateException说明必须拥有lock,注意此异常不需捕捉
public final void notifyAll()
A thread in Java begins as an instance of java.lang.Thread. For the exam, you’ll need to know, at a minimum, the following methods:
start()
yield()
sleep()
run()
You can define and instantiate a thread in one of two ways:
■ Extend the java.lang.Thread class
■ Implement the Runnable interface
方法一:Extending java.lang.Thread
The simplest way to define code to run in a separate thread is to
■ Extend the Thread class.
■ Override the run() method.
下面的例子示例了通过此方法实现的一个thread:
class MyThread extends Thread { public void run() { System.out.println("Important job running in MyThread"); } }
方法二:Implementing java.lang.Runnable
通过实现java.lang.Runnable接口,亦可以定义一个thread,示例如下:
class MyRunnable implements Runnable { public void run() { System.out.println("Important job running in MyRunnable"); } }
注意:因为是implements一个interface,因此你必须实现其public void run();方法(Runnable接口只有这一个方法)
对应于Define a thread的两种方法,Instantiating a thread也分别有两种方法:
方法一
如果你的thread是通过extends java.lang.Thread的方法获得,那么实例化一个Thread就非常简单:
MyThread t = new MyThread(); //这里的MyThread extends Thread的class
方法二
如果你的thread是通过implements Runnable接口的方法获得,那么实例化一个thread就稍微复杂一些,分为两个步骤:
1.MyRunnable r = new MyRunnable(); //这里的MyRunnable是implements Runnable的class
2.Thread t = new Thread(r); //将你的Runnable class传递给一个java.lang.Thread class
//因为只有java.lang.Thread才有用来启动线程的start()
注意:你可以将一个Runnable传递给多个Thread实例,例如:
public class TestThreads { public static void main (String [] args) { MyRunnable r = new MyRunnable(); //带有任务(run()方法)的Runnable Thread foo = new Thread(r); //创建了三个Thread Thread bar = new Thread(r); Thread bat = new Thread(r); } }
上例中:三个Thread运行的任务是独立(三个Thread各自的call stack)且相同的(任务内容是一样的)。
你必须知道Thread的其它形式的构造函数
■ Thread()
■ Thread(Runnable target)
■ Thread(Runnable target, String name)
■ Thread(String name)
■ Thread(ThreadGroup group, Runnable target)
■ Thread(ThreadGroup group, Runnable target, String name)
■ Thread(ThreadGroup group, String name)
Thread的几个有用的方法:
1. public static Thread currentThread() :Returns a reference to the currently executing thread object.
2. public final void setName(String name):Changes the name of this thread to be equal to the argument name.
3. public final String getName():Returns this thread's name.
Methods from the java.lang.Thread Class Some of the methods that can help us influence thread scheduling are as follows:
public static void sleep(long millis) throws InterruptedException public static void yield() public final void join() throws InterruptedException public final void setPriority(int newPriority)
Note that both sleep() and join() have overloaded versions not shown here.
Methods from the java.lang.Object Class Every class in Java inherits the following three thread-related methods:
public final void wait() throws InterruptedException public final void notify() public final void notifyAll()
The wait() method has three overloaded versions (including the one listed here).
Thread States
A thread can be only in one of five states
■ New This is the state the thread is in after the Thread instance has been instantiated, but the start() method has not been invoked on the thread. It is a live Thread object, but not yet a thread of execution. At this point, the thread is considered not alive. 线程实例(java.lang.thread或者其subclass)对象被创建,但是其start()方法还没有被调用。此时线程还不是活动的(alive).
■ Runnable This is the state a thread is in when it’s eligible to run, but the scheduler has not selected it to be the running thread. A thread first enters the runnable state when the start() method is invoked, but a thread can also return to the runnable state after either running or coming back from a blocked, waiting, or sleeping state. When the thread is in the runnable state, it is considered alive. 此时线程已经满足了所有运行所需的条件,只等到thread scheduler选中它就可以运行了。线程第一次进入Runnable状态的标志是,该线程的start()方法被调用。但是这并不是线程进入Runnable状态的唯一方法,处于Running状态和Blocking状态的线程也可以返回到Runnable状态。此时线程是活动的(alive).
■ Waiting/blocked/sleeping OK, so this is really three states combined into one, but they all have one thing in common: the thread is still alive, but is currently not eligible to run. In other words, it is not runnable, but it might return to a runnable state later if a particular event occurs. 1. A thread may be blocked waiting for a resource (like I/O or an object’s lock), in which case the event that sends it back to runnable is the availability of the resource—for example, if data comes in through the input stream the thread code is reading from, or if the object’s lock suddenly becomes available. 2. A thread may be sleeping because the thread’s run code tells it to sleep for some period of time, in which case the event that sends it back to runnable is that it wakes up because its sleep time has expired. 3.Or the thread may be waiting, because the thread’s run code causes it to wait, in which case the event that sends it back to runnable is that another thread sends a notification that it may no longer be necessary for the thread to wait. The important point is that one thread does not tell another thread to block. 也就是说,导致线程Blocking/Sleeping/Waiting的原因都是线程自身代码运行中遇到的,而其它的Thread并不能够通知/告诉/要求当前运行的线程被Block。There is a method, suspend(), in the Thread class, that lets one thread tell another to suspend, but the suspend() method has been deprecated and won’t be on the exam (nor will its counterpart resume()). There is also a stop() method, but it too has been deprecated and we won’t even go there. Both suspend() and stop() turned out to be very dangerous, so you shouldn’t use them and again, because they’re deprecated, they won’t appear on the exam. Don’t study ‘em, don’t use ‘em. Note also that a thread in a blocked state is still considered to be alive. 值得注意的是,处于Blocking状态的thread仍然是活动的(alive).
■ Dead A thread is considered dead when its run() method completes. It may still be a viable Thread object, but it is no longer a separate thread of execution. Once a thread is dead, it can never be brought back to life! (The whole “I see dead threads” thing.) If you invoke start() on a dead Thread instance, you’ll get a runtime (not compiler) exception. And it probably doesn’t take a rocket scientist to tell you that if a thread is dead, it is no longer considered to be alive.
Thread Priorities and Yield
要知道,不同的JVM实现的线程调度机制不同,有的实行优先级抢占策略,有的实行时间片轮转策略。
通常每个thread都有自己的优先级—priority。一般priority用1到10的数字来表示。
注意:Thread类有以下关于线程priority的static final常量:
public static final int MAX_PRIORITY
The maximum priority that a thread can have.
public static final int MIN_PRIORITY
The minimum priority that a thread can have.
public static final int NORM_PRIORITY
The default priority that is assigned to a thread.
Setting a Thread’s Priority
A thread gets a default priority that is the priority of the thread of execution that creates it.
默认地,一个线程的优先级是和创建它的线程相同的。例如:
public class TestThreads { public static void main (String [] args) { MyThread t = new MyThread(); } }
the thread referenced by t 和 the main thread具有相同的优先级, since the main thread is executing the code that creates the MyThread instance.
当然你也可以通过Thread实例的public final void setPriority(int newPriority)方法来为一个线程设定优先级。例如:
FooRunnable r = new FooRunnable(); Thread t = new Thread(r); t.setPriority(8); //为Thread t设定的优先级为8 t.start();
The default priority is 5
关于yield()方法
也就是说,Thread的yield()方法的作用就是让当前线程暂时停止执行,返回到Runnable状态。以便其它的与之具有相同优先级的处于Runnable状态的线程可以获得调度。
但是这一原则性的策略的执行并不会得到JVM的保证。因为,yield()虽然可以保证使得当前正在执行的线程进入Runnable状态,但是并不会保证进入Runnable的该线程不会被thread scheduler再次选中,重新进入Running状态。因为,被yield()方法放进Runnable Pool的该进程会和Runnable Pool中具有相同优先级的进程一样被thread scheduler来考量
The Join() Method
1.public final void join() throws InterruptedException
Waits for this thread to die
2.public final void join(long millis) throws InterruptedException
Waits at most millis milliseconds for this thread to die. A timeout of 0 means to wait forever.
3.public final void join(long millis,int nanos) throws InterruptedException
Waits at most millis milliseconds plus nanos nanoseconds for this thread to die
Synchronizing Code
Write code using synchronized wait, notify, and notifyAll to protect against concurrent access problems and to communicate between threads.
So how do you protect the data? You must do two things:
■ Mark the variables private
■ Synchronize the code that modifies the variables
关于lock和synchronized我们应该记住下面的要点:
■ Only methods can be synchronized, not variables.
只有method可以被synchronized,变量不可以
■ Each object has just one lock.
每个对象只有一个机锁
■ Not all methods in a class must be synchronized. A class can have both synchronized and nonsynchronized methods.
一个class中并非所有的method都必须是synchronized的。一个class可以有synchronized方法,也可以有nonsynchronized方法
■ If two methods are synchronized in a class, only one thread can be accessing one of the two methods. In other words, once a thread acquires the lock on an object, no other thread can enter any of the synchronized methods in that class (for that object).
机锁具有独占性,一旦被一个Thread获得,其他的thread就不能够再拥有。
■ If a class has both synchronized and nonsynchronized methods, multiple threads can still access the nonsynchronized methods of the class! If you have methods that don’t access the data you’re trying to protect, then you don’t need to mark them as synchronized. Synchronization is a performance hit, so you don’t want to use it without a good reason.
Nonsynchronized方法并不会导致对象的lock被激活。但是过多的使用synchronized method会影响性能,所以要慎用。
■ If a thread goes to sleep, it takes its locks with it.
一个线程进入Sleeping状态,他不会释放他所拥有的其它对象的lock
■ A thread can acquire more than one lock.
一个线程可以同时获得多个对象的机锁(lock)
常见的几个Methods小结:
java.lang.Runnable(inerface):
1.public void run()
java.lang.Thread:
java.lang.Thread implements java.lang.Runnable
1.public void start()
2.public void run() from java.lang.Runnable
3.sleep() throws InterruptedException
public static void sleep(long millis) throws InterruptedException
public static void sleep(long millis,int nanos) throws InterruptedException
4. public static void yield()
5. join() throws InterruputedException
public final void join() throws InterruptedException
public final void join(long millis) throws InterruptedException
public final void join(long millis,int nanos) throws InterruptedException
java.lang.Object
1. Wait() throws InterruptedException,必须在synchronized code中,否则掷出异常IllegalMonitorStateException说明必须拥有lock,注意此异常不需捕捉
public final void wait() throws InterruptedException
public final void wait(long timeout) throws InterruptedException
public final void wait(long timeout,int nanos) throws InterruptedException
2. notify(),否则掷出异常IllegalMonitorStateException说明必须拥有lock,注意此异常不需捕捉
public final void notify()
3. notifyAll(),否则掷出异常IllegalMonitorStateException说明必须拥有lock,注意此异常不需捕捉
public final void notifyAll()
发表评论
-
Java 5 并发学习(转)
2012-06-26 14:38 834Java 5 并发学习 在Java5之后,并发线程这块发生 ... -
WeakHashMap和HashMap的区别
2012-02-24 13:42 825http://mzlly999.iteye.com/blog/ ... -
volatile 的高级模式
2012-02-22 13:07 713前面几节介绍的模式涵盖了大部分的基本用例,在这些模式中使用 v ... -
The "Double-Checked Locking is Broken" Declaration
2012-02-22 10:34 939http://www.cs.umd.edu/~pugh/jav ... -
Log4j配置文件详细说明[转]
2012-02-14 10:48 1327属性文件Properties properties属性文件 ... -
Log4j的配置文件
2012-02-14 10:42 790Log4j支持两种配置文件格式,一种是java属性文件(键—值 ... -
单例模式的俩种方式
2012-01-04 14:09 882等等 单例模式的俩种方式: 饿汉式 class Singlet ... -
Mysql连接数据库:PreparedStatement.addBatch()方法
2011-12-23 08:43 57991.Eclipse连接MySQL数据库 mysql>C ... -
java中ArrayList 、LinkList区别
2011-12-21 15:30 1148java中ArrayList 、LinkList、List区别 ... -
Date4j,一个简约的日期处理类库
2011-12-14 10:13 792Java本身的日期类在JDK1.0版本之后就再也没有更新过,同 ... -
How to use Log4j
2011-09-29 13:57 7901. LogManager.getInstance().get ... -
重写hashCode和equals方法(转)
2011-09-27 09:58 1112如果你的对象想散列存 ... -
学习Enum转
2011-09-22 14:11 8451. 关于 Java Enum: 学过 C/C++ 等 ... -
PO BO VO DTO POJO DAO概念及其作用(转)
2011-09-20 09:49 644J2EE开发中大量的专业缩略语很是让人迷惑,尤其是跟一些高手讨 ... -
Thread的实现
2011-09-20 09:47 833Thread的实现 1.extend Thread,then ... -
Adapter模式(转)
2011-08-17 15:48 859[b]GOF《设计模式》一书对Adapter模式是这样描述的: ... -
JVM常见配置汇总
2011-08-15 14:56 1887从这个图中可以看到, ... -
Abstract or Interface
2011-08-11 15:02 700详解java中的抽象类和接 ... -
HashMap HashTable TreeMap
2011-08-11 13:45 941Map中我们通过对象来对对象进行索引,用来索引的对象叫做key ... -
多线程死锁问题(转)
2011-08-10 19:42 563前天俺们谈到了加锁,但是在使用加锁的同时又会带来一个问题,就是 ...
相关推荐
基于RT-Thread实现的小游戏(贪吃蛇、俄罗斯方块),参考博客:https://blog.csdn.net/weixin_42653531/article/details/106422177
继承Thread类: 1必须重写run 方法:里面放置的实际的线程体 2 启动线程: 3创建Thread对象 4调用Thread对象的start 方法启动线程
JAVA100例之实例60 继承Thread实现多线程
理解多线程,写一个多线程应用程序,要求能在用户级实现线程的调度,如启动、挂起、恢复、停止,的C thread、java thread实现。
应用 RT-Thread 实现蜂鸣器播放器简介这是一个应用 RT-Thread 实现蜂鸣器播放器的教程,共包含 5 节的内容,介绍了由浅入深,一步步实现一个蜂鸣器播放器的过程。此播放器支持 歌曲列表、上一曲、下一曲、暂停/播放...
网上大部分写线程模式都是重写run函数实现的,但网上有大牛建议通过MoveToThread函数实现线程,现制作简易的线程模板分享一下
JavaFX + SQLite + Thread实现多操作系统下的文件搜索工具源码.zip
工程源码适合嵌入式软件初学者了解基于STM32和RT-Thread实现网络通讯、Modbus-TCP协议的方法,也包含了I2C总线、eeprom设备读写的相关操作,以及finsh组件函数添加方法。 资料中包含开发板原理图。
win32下实现自定义Thread
继承Thread类 1 实现Runable接口 2 继承Thread类: 3 必须重写run 方法:里面放置的实际的线程体 4 启动线程: 5 创建Thread对象 6 调用Thread对象的start 方法启动线程 7 在子类中定义static静态变量实现资源共享
rt-thread 操作系统,绘本故事机开发文档,内核“小”而“美”,• 线程及其调度、 • 信号量、 • 消息队列和邮箱、 • 内存管理、 • 定时器、 • 设备管理
这是实验一中thread 文档,通过8个测试,是timer总的.希望对大家有帮助。
c++实现CThread类,源码完整,可直接使用。多线程必用
基于STM32的平台,跑rt-thread的实时系统,与swc11ac芯片进行串口通信,获取传感器终端ble,lora的数据,通过网口,把数据上传到iot平台.zip嵌入式优质项目,资源经过严格测试可直接运行成功且功能正常的情况才上传...
主要介绍了python继承threading.Thread实现有返回值的子类实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
主要介绍了python开发之thread实现布朗运动的方法,实例分析了Python基于多线程实现绘图的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下
基于W600嵌入式WiFi芯片的RT-Thread智能宿舍指纹门锁。主控芯片使用W600 的 TW-03 WIFI模组,指纹识别使用 FPC1020A,这里开门使用MG996R舵机拉开门锁。W600运行RT-Thread操作系统并连接OneNET进行数据交互。使用 ...
RT-Thread最新版本。完整版。包含各种丰富的BSP。 GitHub上下载慢,上传在此便于使用。
"Thread 线程类实现 Runnable 接口" Thread 线程类是 Java 中 Thread 和 Runnable 接口的实现,它提供了线程的基本操作和管理。下面是对 Thread 类的详细介绍: 1. Runnable 接口 Runnable 接口是 Thread 类的...
本文介绍了自己移植RT-Thread操作系统,到自己的开发板的一些心得和调试笔记,芯片:stm32f407vet6。