各位专家好,小弟有个问题向你们请教一下,困惑很久,实在痛苦万分啊 这个问题还是有点研究价值~~一般用ajax后,交互性强了很多,用起来比较爽但是LZ提出的问题,也确实存在除非用自己的server 请唠叨来解决 哈哈~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http请求是无状态的,一次发送接收算一次,没办法一直连着 我在网上找到一篇这个,不知能不能联系上啊:php实现后台线程持续运行 2005年12月21日00:24星期三 [技术相关] 见codestartthread.php<?PHPinclude_once("System/SharedMemory.php");$shared_memory =& System_SharedMemory::factory();set_time_limit(0);ignore_user_abort(true);$pid=(int)$shared_memory->get("thread_pid");if($pid>0){ die("线程已经在活动中");}$pid=posix_getpid();$shared_memory->set("thread_pid",$pid);while(1){ $fp=fopen(ROOT_PATH."temp/running.txt","a+"); fwrite($fp,date("Y-m-d H:i:s")."\n"); fclose($fp); sleep(5);}?>stopthread.php<?phpinclude_once("System/SharedMemory.php");$shared_memory =& System_SharedMemory::factory();$pid=(int)$shared_memory->get("thread_pid");if($pid==0){ die("线程并没有在活动");}if(posix_kill($pid,9)){ $shared_memory->set("thread_pid",0); echo "线程终止";}else{ echo "线程无法终止";}?>在浏览器中访问startthread.php之后,把浏览器关掉。要终止访问stopthread.php。SharedMemory是pear的一个project,具体情况大家可以google。这里互斥使用了一个变量thread_pid,其实也可以使用一个文件,打开,flock住。 求个字符串切分正则 如何分组查询并现实结果? url 重定向 关于php判断问题 自己做了个程序,想开源,不知有人要吗?http://www.nnrsc.com 后台权限检查函数问题! 真不爽,回答问题还招‘人’骂(是人的作为不),强烈建议封ID!举报!!!!!!!!!!!!!!!! 有关phpmyadmin php怎么样调用MSSQL2000中的存储过程? 紧急等待!! 不能上传图片的问题 supplied argument is not a valid OCI8-Statement resource
2005年12月21日00:24星期三 [技术相关]
见codestartthread.php<?PHP
include_once("System/SharedMemory.php");
$shared_memory =& System_SharedMemory::factory();
set_time_limit(0);
ignore_user_abort(true);
$pid=(int)$shared_memory->get("thread_pid");
if($pid>0)
{
die("线程已经在活动中");
}
$pid=posix_getpid();
$shared_memory->set("thread_pid",$pid);
while(1)
{
$fp=fopen(ROOT_PATH."temp/running.txt","a+");
fwrite($fp,date("Y-m-d H:i:s")."\n");
fclose($fp);
sleep(5);
}
?>stopthread.php
<?php
include_once("System/SharedMemory.php");
$shared_memory =& System_SharedMemory::factory();
$pid=(int)$shared_memory->get("thread_pid");
if($pid==0)
{
die("线程并没有在活动");
}
if(posix_kill($pid,9))
{
$shared_memory->set("thread_pid",0);
echo "线程终止";
}
else
{
echo "线程无法终止";
}
?>在浏览器中访问startthread.php之后,把浏览器关掉。要终止访问stopthread.php。SharedMemory是pear的一个project,具体情况大家可以google。这里互斥使用了一个变量thread_pid,其实也可以使用一个文件,打开,flock住。