• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP Java bean Dead Lock

 
Nehal Dave
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am using a java bean in JSP.
This bean calls a perticular api which tries to connect to some legacy back end system.
Sometimes the api which i call respond back after say 10 mins & its 2 long for a user to wait .
I want to find out a way where while calling this api from java bean is their any way to set time out ...
For eg..
public class A
{

public static int endless()
{
int i = 0;

while(i!=1)
{

}
return i;
}
}

public class B
{

public static void main(String args[])
{
System.out.println("Before A ");
A.endless();
System.out.println("After A ");
}
}

This above code creates a dead lock which some times happen in our system. i want to add a timer mechanism while calling A.endless() ....
Any ideas how..
Cheers
Nehal.
 
srinivas madugula
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai
i dont know what your r making. but this may do the task
----------------------------------------
class B implements Runnable{
public void run(){
A.endless();
}
public static void main(String[] args){
Thread t=new Thread(new B());
t.start();
Thread.sleep(//specify time out);

// handle the code for timer here
want to stop the thread
t.destroy();
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!