Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I have successfully integrated PHP5 and Java using PHP-Java bridge.
Can any one help how we can run a simple Thread application by importing java.lang.Thread or implementing Runnable interface in PHP. This thing has to be run on terminal and not on webserver.
A simple Thread program which i run is :Code: Select all
<?
$thread=new Java('java.lang.Thread');
for($i=0;$i<10;$i++){
echo " \n ". $i . " hello ";
$thread->sleep(1000);
}
?>Code: Select all
C:\test\javatest>php test4.php
0 hello
1 hello
2 hello
3 hello
4 hello
5 hello
6 hello
7 hello
8 hello
9 helloCode: Select all
<?
class MyThread{
function __construct($msg){
$obj=new JavaClass("java.lang.Thread");
$thread=$obj->newInstance();
$thread->setName($msg);
echo " \nThread " . $thread->getName() . " Running ";
$thread->sleep(3000);
}
}
$a= new MyThread("hello world");
$b= new MyThread("there is me");
?>Code: Select all
C:\test\javatest>php test6.php
Thread hello world Running
Thread there is me RunningPimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]