class Producer(threading.Thread):def __init__(self,data_queue,*args,**kwargs): super(Producer, self).__init__(*args,**kwargs)self.data_queue = data_queue
``
1.最近看到这段代码,记录一哈自己对这段代码的理解(当然请教了别人的),class producer 是建立了一个名字为Producer 的类,threading.Thread 是建立了一个多线程的类。`class Producer(threading.Thread) 表示Producer是Thread 的子类,他的父类是Thread.
2 def __init__(self,data_queue,*args,**kwargs), 为类Producer 的初始化函数,#def_init_是类的一个初始化方法,他在类的初始化调用后会自动调用,不需要手动调用。self 表示这个对象Producer 本身,data_queue ,*args,**kwargs表示是传递的参数, ,*args表示传递单个数值的,不固定长度,比如列表,数组,,**kwargs传递的键值对,如字典。
3,super(Producer, self).__init__(*args,**kwargs),表示将父类需要的参数传递给父类,即(*args,**kwargs)
4,self.data_queue = data_queue,是Producer 自己独有的参数。
详细解决方案
Python子类父类多线程理解class Producer(threading.Thread):
热度:63 发布时间:2023-12-19 07:00:58.0
相关解决方案
- Exception in thread "main" org.hibernate.HibernateException: /hibernate.cfg.xml解决办法
- Class not found: com.mchange.v2.c3p0.ComboPooledDataSource,该怎么处理
- org.apache.jasper.JasperException: Unable to compile class for JSP:该怎么解决
- org.apache.jasper.JasperException: Unable to compile class for JSP:解决思路
- thread(线程)中用spring注入不成功有关问题
- !使用JDNI时,报 Cannot create JDBC driver of class '' for connect URL 'null'
- Unable to load class for JSP,该如何处理
- 新手Dialect class not found
- Caused by: org.hibernate.MappingException: Association references un地图ped class: com.elone.pm.product.dao.TAttribute
- Error creating bean with name 'sessionFactory' defined in class path resource解决方法
- Unable to compile class for JSP找不出异常
- Could not load JDBC driver class 咋回事
- No setter found for property 'sessionFactoroy' in class 'com.iBBS.dao.impl.UserI解决思路
- getHibernateTemplate().get(entity.Class,serializabel id) 如何报java.lang.NullPointerException的错误
- 小弟我在tomcat里的Server.xml部署web项目报Error instantiating servlet class
- Exception in thread "main" java.lang.UnsupportedClassVersionError:有关问题
- Jsp + Oracle 怎么取回id,报错getInt not implemented for class oracle.jdbc.driver.T4CRo
- ssh项目hibernate 异常:org.hibernate.MappingException: Association references unmapped class: Message
- java.lang.NoClassDefFoundError: Could not initialize class cn.elvis.utils.JdbcUt,该如何处理
- Cannot load JDBC driver class 'com.microsoft.jdbc.sqlserver.SQLServerDriver'解决方法
- class path resource [applicationContext.xml] does not exist解决方法
- ids for this class must be manually assigned before calling save(): po.Project解决方法
- Thread.sleep() 有关问题
- Exception in thread "main" java.lang.NullPointerException,该怎么处理
- 小弟我的程序中Exception in thread "main" java.lang.NullPointerException如何解决
- class not found error,该如何处理
- 初学急求(待高手指导)java.lang.InstantiationException: Class not a MIDlet?已经写了MIDlet类,如何修改
- 用eclipse打包jar后运行,弹出异常could not find main class
- eclipse class not found 愁死了解决方法