Hello, experts, i have an problem about interrupt()
here is my code, i wanna test what the client requested/posted ,but it seems that i can't interreput other thread which in io blocked ,how can i solve this? thanks!
package yestalk.playground;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Date;
public class STC
public static void main (String[] args) throws Exception
ServerSocket ss = new ServerSocket(8889);
int i = 0;
long start;
while (true)
System.out.println("\r\n------------ "+ (i++));
Socket so = ss.accept();
InputStream ins = so.getInputStream();
InputStreamReader insr = new InputStreamReader( ins, "UTF-8");
int c;
try
start = System.currentTimeMillis();
while((c = insr.read()) != -1)
System.out.print((char)c);
new Thread(new STC.TimerBreaker(Thread.currentThread(),start,5000)).start();
}catch(Exception e)
System.out.println("timer breaker interrupted me: "+e.getMessage());
}finally
insr.close();
so.close();
static class TimerBreaker implements Runnable
long start;
long interval;
long current;
Thread ct;
public TimerBreaker (Thread t,long start,long interval)
this.ct=t;
this.start=start;
this.interval=interval;
public void run ()
while(true)
try
Thread.sleep(500);
current = System.currentTimeMillis();
System.out.println((current-start)>interval);
if((current-start)>interval)
ct.interrupt();
System.out.println(" is read thread Interrupted: "+ct.isInterrupted());
System.out.println(" is read thread still alive: "+ct.isAlive());
break;
catch (Exception e)
System.out.println("timeBreaker exception: "+e.getMessage());
System.out.println("timer thread breaked!!!!!!!!!!!!!!!!!!!!!!!");
}i am waiting on board,thanks very much.
sorry, i change my code ,let it more clear.i wanaa see what did the http client requested/posted, but i don't wan't parse the http protocol to know when to close connection precisely,so i think 5s is enough to read all client requested/posted,so i would like "continue read" but close connection in 5s. and the server should continue listening....
but as you say that : java.net.Socket I/O methods aren't specified to be interruptible.
and i see the doc :
public void interrupt() // it's not static method, so i think it cant apply to an instance.
Unless the current thread is interrupting itself, which is always permitted, the checkAccess method of this thread is invoked, which may cause a SecurityException to be thrown.
does interrupt other Thread use another Thread is a proper act?
how can't i achieve my objective? thanks very much.
and , sorry: i change my code three time. now it is not try to establish a new thread every char read.
package yestalk.playground;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Date;
public class STC
public static void main (String[] args) throws Exception
ServerSocket ss = new ServerSocket(8889);
int i = 0;
long start;
while (true)
System.out.println("\r\n------------ "+ (i++));
Socket so = ss.accept();
InputStream ins = so.getInputStream();
InputStreamReader insr = new InputStreamReader( ins, "UTF-8");
int c;
try
new Thread(new STC.TimerBreaker(Thread.currentThread(),5000)).start();
while((c = insr.read()) != -1)
System.out.print((char)c);
}catch(Exception e)
System.out.println("timer breaker interrupted me: "+e.getMessage());
}finally
insr.close();
so.close();
static class TimerBreaker implements Runnable
long interval;
Thread ct;
public TimerBreaker (Thread t,int interval)
this.ct=t;
this.interval=interval;
public void run ()
try
Thread.sleep(interval);
ct.interrupt();
System.out.println(" is read thread Interrupted: "+ct.isInterrupted());
System.out.println(" is read thread still alive: "+ct.isAlive());
catch (Exception e)
System.out.println("timeBreaker exception: "+e.getMessage());
}Edited by: Johnny on Oct 19, 2008 11:18 PM
Similar Messages
-
Hello apple
I have the problem with my iPhone and my friends have this problem too.
My iPhone have the problem about calling and answer the call. When I use my iPhone to call I can't hear anything from my iPhone but the person that I call can answer it but when answer both of us can't hear anything and when I put my iPhone to my face the screen is still on and when I quit the phone application and open it again it will automatic call my recent call. And when my friends call me my iPhone didn't show anything even the missed call I'm only know that I missed the call from messages from carrier. Please check these problem I restored my iPhone for 4 time now in this week. I lived in Hatyai, Songkhla,Thailand and many people in my city have this problem.
Who have this problem??Apple isnt here. this is a user based forum for technical questions. The solution is to restart, reset, and restore as new which is in the manual after that get it replaced for hard ware failure. if your within your one year warranty its replaced if it is out of the warranty then it is 199$
-
Hello.i have a problem about my MacBook white Version OS X 10.5.8.
Hello.i have a problem about my MacBook white Version OS X 10.5.8. Why I cant update the new iTunes in my MacBook. when i update the software and at the end it appear (The digital signature for this package is incorrect. The package may have been tampered with or corrupted since being signed by Apple). I don't understand what is the problem.plz help me.
The new version of iTunes (iTunes 11), requires 10.6.8 OS or higher.
-
Hello! I have a problem with a credit card. I bought one program, after that i wanted buy one more, but it wrote that with my card something wrong. After that i wanted change my card (VISA) on "NONE". But there no NONE! I can't download FREE apps! Than I wanted make new account and select NONE, but there no NONE, there only cards. Help, please!
Hey Shamannnig!
Here is an article that can explain a little more about this situation:
Why can’t I select None when I edit my payment information?
http://support.apple.com/kb/ts5366
Thanks for using the Apple Support Communities!
Cheers,
Braden -
Good am sir i have an problem about may hp touchpad i just update it for android but i am not succes
good am sir i have an problem about may hp touchpad i just update it for android but i am not success to install it what can i do for it
This question was solved.
View Solution.Installing another Operating System to your Touchpad is an option with inherent risk, and is not supported here on this Forum.
Try researching your issue over at http://www.webosnation.com. They have an entire forum section devoted to "Android on the HP TouchPad".
WyreNut
I am a Volunteer here, not employed by HP.
You too can become an HP Expert! Details HERE!
If my post has helped you, click the Kudos Thumbs up!
If it solved your issue, Click the "Accept as Solution" button so others can benefit from the question you asked! -
hi everyone, i have a problem about my iphone 4S, doesn't work with wifi connection and bluetooth since upgrade to the IOS 7.0.3. Can anyone can help me tosolve this problem?????Thank's regards paulus
Try the suggestions here to see if they resolve your problem:
http://support.apple.com/kb/ts1559
If these don't work you may have a hardware problem. Visit an Apple store for an evaluation or contact Apple Support. -
Hello everyone, I have a problem when I sync my apple device. I plug it in and a message comes up saying, this device could not be synced because this computer is not authorized for the purchased items on this phone. I already tried to authorize again, after deautherizing it. HELP ME PLEASE
Hi applerinneedforhelp,
Thanks for visiting Apple Support Communities.
If iTunes is asking you to authorize the computer, and you've already done so, the troubleshooting steps in this article can help:
iTunes repeatedly prompts to authorize computer to play iTunes Store purchases
http://support.apple.com/kb/ts1389
Regards,
Jeremy -
Hello.
I have a problem with OEL 6.5 and ocfs2.
When I mount ocfs2 with mount -a command all ocfs2 partitions mount and work, but when I reboot no ocfs2 partitions auto mount. No error messages in log. I use DAS FC and iSCSI FC.
fstab:
UUID=32130a0b-2e15-4067-9e65-62b7b3e53c72 /some/4 ocfs2 _netdev,defaults 0 0
#UUID=af522894-c51e-45d6-bce8-c0206322d7ab /some/9 ocfs2 _netdev,defaults 0 0
UUID=1126b3d2-09aa-4be0-8826-0b2a590ab995 /some/3 ocfs2 _netdev,defaults 0 0
#UUID=9ea9113d-edcf-47ca-9c64-c0d4e18149c1 /some/8 ocfs2 _netdev,defaults 0 0
UUID=a368f830-0808-4832-b294-d2d1bf909813 /some/5 ocfs2 _netdev,defaults 0 0
UUID=ee816860-5a95-493c-8559-9d528e557a6d /some/6 ocfs2 _netdev,defaults 0 0
UUID=3f87634f-7dbf-46ba-a84c-e8606b40acfe /some/7 ocfs2 _netdev,defaults 0 0
UUID=5def16d7-1f58-4691-9d46-f3fa72b74890 /some/1 ocfs2 _netdev,defaults 0 0
UUID=0e682b5a-8d75-40d1-8983-fa39dd5a0e54 /some/2 ocfs2 _netdev,defaults 0 0What is the output of:
# chkconfig --list o2cb
# chkconfig --list ocfs2
# cat /etc/ocfs2/cluster.conf -
Hello ! i have a question about my Hard's Disc storage space. I have Mac book Pro 11" Retina with hard disk 120 GB . I want to make this update but its impossible because of no free space. And now i want to ask. Its 120 GB full space but i dont know how. It tells me lets say i have 30 GB movies but i dont have anything ! Can you help me with any way ? If i can do something to see what movies let's say means !
Thank you !!Hope this helps.
1. Empty Trash.
http://support.apple.com/kb/PH10677
2. Start up in Safe Mode
http://support.apple.com/kb/PH11212
3. Delete "Recovered Messages", if any.
Hold the option key down and click "Go" menu in the Finder menu bar.
Select "Library" from the dropdown.
Library > Mail > V2 > Mailboxes
Delete "Recovered Messages", if any.
Empty Trash. Restart.
4. Repair Disk
Steps 1 through 7
http://support.apple.com/kb/PH5836
5. Disk space / Time Machine ?/ Local Snapshots
http://support.apple.com/kb/ht4878
6. Re-index Macintosh HD
System Preferences > Spotlight > Privacy
http://support.apple.com/kb/ht2409
If this does not help, you have to buy an external HD and move your movies photos.etc to
the external HD. -
hello friends i have a problem in my ipod touch 3g it has 4.2.1 version of software but it doesnot supports any apps so how to update the ios 5 or more than this please anybody help me..i am in trouble.
I suspect you really have a 2G iPod. Those can only go to iOS 4.2.1.
Identifying iPod models
iPod touch (3rd generation)
iPod touch (3rd generation) features a 3.5-inch (diagonal) widescreen multi-touch display and 32 GB or 64 GB flash drive. You can browse the web with Safari and watch YouTube videos with Wi-Fi. You can also search, preview, and buy songs from the iTunes Wi-Fi Music Store on iPod touch.
The iPod touch (3rd generation) can be distinguished from iPod touch (2nd generation) by looking at the back of the device. In the text below the engraving, look for the model number. iPod touch (2nd generation) is model A1288, and iPod touch (3rd generation) is model A1318.
Otherwise connect to yor computer and update via iTunes. Yo need iTunes 10 or later on the computer.
To more easily find compatilbe apps for 4.2.1
iOSSearch - search the iTunes store for compatible apps.
Vintapps 3.1.3 - paid app.
Apple Club - filter apps by iOS version.
Discussion post by msgarmar - technique to sort apps by date. -
Hello Experts, I have a question, how I can import "linq" file to ms sql?
Hello Experts, I have a question, how I can import linq (OpenUIPlayersDB.linq) file to ms sql? Form Sample OpenUI applications?
BR
LukasLukas,
The .linq file is just a sql script. You can either change the extension to .sql and directly open and run in SQL Server Management studio or open the file directly.
The script is designed to run against SQL server so if you are using another database type you may need to tweak the script (date/time formats, data types, column select statement).
Also, last I checked the name of the table from the script (OpenUIPlayers) doesn't match the table name from the OpenUI-app.agxz export so you will also need to adjust either the script in the export or the name of the imported table once you finish loading it.
--Bill -
HT2506 Hello guys, I have a question about Preview - How do you loop a slideshow?
Hello guys, I have a question about Preview - How do you loop a slideshow?
Had the "loop" feature using Preview in 10.4.11; upgaded to 10.5.8 and it's gone. Don't you have to work at "Taking" it away? Makes no sense. Now you have to look for a third market for something that was included in Preview since the first version was launched. ....I don't get this one.
-
Hello. I have a problem with my Photoshop Elements 12 programm. I had restart my computer and I wanted to instal my Photoshop Elements 12 again but the sytem didn't accept my serial number. I get no answer per Mail and I didn't reach someone on my phone. Can you help me please? Thanks a lot Nana
1) Apps are not part of the backup, only data stored by 3rd party apps. But you can redownload the apps for free again if you use the same account you did when you bought them the first time. http://support.apple.com/kb/HT2519
2) See this article http://support.apple.com/kb/HT1766 and find out what's in your backup.
3) Backup your itunes+ library (http://support.apple.com/kb/HT1382 and http://support.apple.com/kb/HT1751), which will copy your Mobile Applications folder, and save your iphone backup folder as well
In other words, maintaining a backup of your computer is essential.
When you resync your apps from your computer to the phone, make sure your computer is authorized again. http://support.apple.com/kb/HT1420 -
Hello. I have a problem. I cannot delete any apps from my ipad. It won't even wiggle when i tap and hold on the icon. There's also no restrictions and passcodes in my settings. My photos on camera roll even get lost once i shut down my ipad. Please help.
The preinstalled apps, those that came as part of the iOS, cannot be deleted and will not shake or provide the black circle-X for deletion.
Others should do that if you touch and hold for a few seconds.
If they are not, do a reboot by holding both the power and home buttons until the apple logo appears and it restarts, ignoring the red slider if that appears. -
Hello. I have a problem. I live in Armenia, now I am in Guangzho (China) and i have lost my Iphone 4S. Tryed to find in icloud, no result. it seems the finder has switched off or deleted my apple ID. Please help me. Can I do anything with IMEI code?
IMEI number is no use.
If you can't track it using find my phone.
Then report the lost to the local authority and your phone carrier.
change your passwords.
Maybe you are looking for
-
Authorization check for Open and Close Periods ( OB52)
Dear Experts, We have created ZOB52 for Opening and closing periods. This is replica of Tcode: OB52 with some other developments that we required. Here for resticting user I had tried authorization Object: F_BKPF_BUP for partic
-
Data recovery help and options
If you don't want to read the entire diatribe, please answer: Any suggestions as to which data recovery app is appropriate for a ThunderBolt Seagate GoFlex 1TB? It's been 21 hours, should I stop and restart First Aid? I have a MBP15R that is about
-
Sale Order costing - Updation of SD conditions
Hi SAP Gurus, I would like to know how the cost calculated in Sale Order costing is updated in VPRS Condition type Pricing Procedure. Where do we do the settings for updation of the same You Valuable answer would be suitably rewarded Thanks in Advanc
-
Cisco ISE integration with AD fails
Cisco ISE Ver: 1.1.2.145 Windows : Win 2003 Server I am attempting to integrate ISE with AD, but ISE won't join AD and joining attempts fails, though I am able to add same domain as external LDAP identity store ? 1.user used to join the domain has ad
-
Newbie ? - Error Opening Database After Recovery
Hi All- I'm new to Oracle and am using 9i - I'm working on cloning our Production db for a Test db. I shutdown the Production db and copied all the files from that db into my Test db - I then started my Test db and recovered it. I am now trying to OP