Sunday, November 18, 2007

J2ME : Create New Thread under commandAction

Guys, if you happen receive this warning, "To avoid potential deadlock, operations that may block, such as networking, should be performed in a different thread than the commandAction() handler." and your J2ME application doesn't work properly, here is quick work around to do it right :

here is the original lines :


public void commandAction(Command c, Displayable s)
{
if (c == cmCall)
{
display.setCurrent(this);
try
{
call_some_function_that_call_network_function();
}
catch (Exception e)
{
System.out.println(e.toString());
}
}
else if (c == cmExit)
{
// the rest command
}
}


and here is the modified lines :

public void commandAction(Command c, Displayable s)
{
if (c == cmCall)
{
display.setCurrent(this);
try
{
new Thread(new Runnable()
{
public void run()
{
try{
call_some_function_that_call_network_function();
} catch(IOException e) {}
}
}).start();
}
catch (Exception e)
{
System.out.println(e.toString());
}
}
else if (c == cmExit)
{
// the rest command
}
}

Forward Port on Cisco PIX for torrent

In case somebody need to forward the torrent port to open outside connection to inside computer, here is my working PIX configuration, its running on PIX-515E.

note : I am using utorrent 1.7.5 with port 35241 to receive outside connection, my outside PIX ip lets say its 4.2.2.1 and my PC using internal ip 10.10.10.231

======================
access-list outside_in permit tcp any host 4.2.2.1 eq 35241
static (inside,outside) tcp 4.2.2.1 35241 10.10.10.231 35241 netmask 255.255.255.255 0 0
access-group outside_in in interface outside

======================

only need 3 lines above to make your torrent share the file faster, and make little icon on utorrent below bar green.

current

last archive