• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

JSP Java bean Dead Lock

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic