草庐IT

thread_safe

全部标签

php - 如何使用PHP//Thread//Mutex//Cond

PHP现在显然支持Thread类(class)。还有一个Mutex和Cond类(class)。尽管如此,还是需要用好的选项编译它并添加一个PECL扩展来拥有它。有从哪里开始的好教程吗?清楚地表明每个类/方法的合理使用的东西。我只是不知道如何处理这些类。我需要一些具体的例子来做非常简单的事情,并展示尽可能多的方法。谢谢。 最佳答案 它已经在pecl上发布,windows在github页面上下载...如果可以的话,git(源代码),更新的代码...http://pthreads.org包含更多信息,也可以查看示例文件夹...如果您对需要

php - "phpinfo(): It is not safe to rely on the system' s 时区设置...”

这个问题在这里已经有了答案:"date():Itisnotsafetorelyonthesystem'stimezonesettings..."(25个答案)关闭6年前。在为Blue.box(FreeSwitchPBX的前端)运行php安装脚本时,我收到有关时区故障的错误。然后我开始挖掘。我不确定此时发生了什么。但这是我所拥有的:我在我的public_html目录中创建了一个info.php文件,其中包含一行:我得到这个错误和输出Warning:phpinfo():Itisnotsafetorelyonthesystem'stimezonesettings.Youarerequired

安卓线程 : is it necessary to wait for threads to start before "join"ing them?

我正在实现Android“服务”。在它的“onCreate”中,我想启动并等待另一个线程的完成。ClientServiceLoop是一个Runnable,在run()中有一个while(true)循环,具有简单的返回条件。@OverridepublicvoidonCreate(){super.onCreate();mClientServiceLoopThread=newThread(mClientServiceLoop=newClientServiceLoop(),"ClientServiceLoop");mClientServiceLoopThread.start();try{mCl

android - GoogleAuthUtil.getToken() 抛出 : RuntimeException: Can't create handler inside thread that has not called Looper. prepare()

这个GoogleAuthUtilgetToken()调用:Stringtoken=GoogleAuthUtil.getToken(appContext,accountName,scope);偶尔会因以下异常而失败:java.lang.RuntimeException:Can'tcreatehandlerinsidethreadthathasnotcalledLooper.prepare():ak:GooglePlayServicesNotAvailableatcom.google.android.gms.auth.GoogleAuthUtil.a(UnknownSource)atcom

android - 事件总线 : What are some differences among each thread modes?

根据EventBusdoc,EventBus用来传递线程的线程模式有4种:onEvent()PostThreadGoodforsimpletasksonEventMainThread()MainThreada.k.a.UIThreadGoodforUIchangesonEventBackgroundThread()BackgroundTreadUsingsinglethread,deliveringeventssequentially.Goodforexecutionrequiringmoderateamountoftime.onEventAsync()AsyncUsingsepara

android - RxJava Thread.sleep 在另一个线程中

如何在Android中使用RxJava每隔一秒更新一次UI?我正在尝试做这样的事情:for(inti=0;iupdateTime());//updatetextView}privateintgetSleep(){try{Thread.sleep(1000);}catch(InterruptedExceptione){e.printStackTrace();}return0;}但是Thread.sleep()在ui线程中执行。我做错了什么? 最佳答案 Observable.interval(1,TimeUnit.SECONDS)//e

android - 使用 RxJava 避免 Thread.sleep

我对这个方法应用了observable,但是在调用这个方法之后,它说主线程上的工作太多了。感谢任何帮助funisBatteryHealthGood():Observable{varcount=0intent=context.registerReceiver(broadCastReceiver,IntentFilter(Intent.ACTION_BATTERY_CHANGED))while(batteryStatus==null&&count 最佳答案 我的解决方案是通过使用intervaloperator来避免使用Thread.s

安卓媒体播放器 : how to stop a thread before finishing activity

我在android中创建了一个mediplayer,它有一个可运行的后台线程,用于保持时间搜索器的更新privateRunnablemUpdateTimeTask=newRunnable(){publicvoidrun(){longtotalDuration=mediaPlayer.getDuration();longcurrentDuration=mediaPlayer.getCurrentPosition();//....settingtextviewsofdurations//...convertingmillitomm:ssandsetProgress(progress)mHa

android - 如何确定性地使用 std::this_thread::yield() ?

在开发基于VoIP的应用程序时,我们有一个通用的多线程C++11模块。它在iOS、MacOS中运行良好,但在Android中发现线程调度困难。可选的设计说明(仅在感兴趣时)我有几个线程与消息队列一起运行。Master(将数据写入SSL_Read队列中接收的套接字)SSL_Read(从SSL读取数据并更新其队列)SSL_Write(将直接从Socket线程接收的数据写入SSL)每个套接字线程(从套接字读取数据并发送到SSL_Write队列)1-2是相关的,3-4是相关的。我观察到在许多调用期间,只有2个线程正在运行,而其他2个线程没有运行时间。由于观察到1路语音路径。问题我怀疑这是一个A

java - 为什么我的 android 应用程序在调用 Thread.sleep 时跳帧?

我正在编写一个android应用程序,它需要在千分之几秒内显示一些文本,然后再次将其显示为空白。我现在所拥有的是它显示文本,然后使用Thread.sleep,然后将文本设置回null。相反,当我按下按钮时,应用程序会挂起设定的时间,文本永远不会出现,并且logcat显示“跳过xxx帧!应用程序可能在其主线程上做了太多工作。”这是怎么回事,是否有更好的处理方法? 最佳答案 尝试使用可运行的。privateHandlermHandler=newHandler();//codetomaketextappear...mHandler.pos