Working with threads

hello all.
I find some program that will help me in my work.
but know i don't know how to change it that it will fit my project. i just want to work with thread pool. i find some code that can do this.
mu problem is that i don't know how to change the task and the run functions in that program because they are interface. and when i do change them I get all the code errors.
can you give me an example how can i change this code to do some, like that the task will print something or do something else.
the code is:
thanks alot!
* To change this template, choose Tools | Templates
* and open the template in the editor.
package work2;
import java.util.ArrayList;
import java.util.List;
* @author vitaly87
public class ThreadPool {
/** Simple thread pool. A task is executed by obtaining a thread from
* the pool
  /** The thread pool contains instances of {@link ThreadPool.Task}.
  public interface Task {
    /** Performs the task.
     * @throws Throwable The task failed, and the worker thread won't be used again.
    void run() throws Throwable{}
    /** A task, which may be interrupted, if the pool is shutting down.
    public interface InterruptableTask extends Task {
        /** Interrupts the task.
         * @throws Throwable Shutting down the task failed.
        void shutdown() throws Throwable;
    private class Poolable {
        private boolean shuttingDown;
        private Task task;
        private Thread thread;
        Poolable(ThreadGroup pGroup, int pNum) {
            thread = new Thread(pGroup, pGroup.getName() + "-" + pNum){
                public void run() {
                    while (!isShuttingDown()) {
                        final Task t = getTask();
                        if (t == null) {
                            try {
                                synchronized (this) {
                                    if (!isShuttingDown()  &&  getTask() == null) {
                                        wait();
                            } catch (InterruptedException e) {
                                // Do nothing
                        } else {
                            try {
                                t.run();
                                resetTask();
                                repool(Poolable.this);
                            } catch (Throwable e) {
                                discard(Poolable.this);
                                resetTask();
            thread.start();
        synchronized void shutdown() {
            shuttingDown = true;
            final Task t = getTask();
            if (t != null  &&  t instanceof InterruptableTask) {
                try {
                    ((InterruptableTask) t).shutdown();
                } catch (Throwable th) {
                    // Ignore me
            task = null;
            synchronized (thread) {
                thread.notify();
        private synchronized boolean isShuttingDown() { return shuttingDown; }
        String getName() { return thread.getName(); }
        private synchronized Task getTask() {
            return task;
        private synchronized void resetTask() {
            task = null;
        synchronized void start(Task pTask) {
            task = pTask;
            synchronized (thread) {
                thread.notify();
  private final ThreadGroup threadGroup;
  private final int maxSize;
  private final List waitingThreads = new ArrayList();
  private final List runningThreads = new ArrayList();
  private final List waitingTasks = new ArrayList();
  private int num;
  /** Creates a new instance.
   * @param pMaxSize Maximum number of concurrent threads.
   * @param pName Thread group name.
  public ThreadPool(int pMaxSize, String pName) {
    maxSize = pMaxSize;
    threadGroup = new ThreadGroup(pName);
  synchronized void discard(Poolable pPoolable) {
    pPoolable.shutdown();
        runningThreads.remove(pPoolable);
        waitingThreads.remove(pPoolable);
  synchronized void repool(Poolable pPoolable) {
        if (runningThreads.remove(pPoolable)) {
            if (maxSize != 0  &&  runningThreads.size() + waitingThreads.size() >= maxSize) {
                discard(pPoolable);
            } else {
                waitingThreads.add(pPoolable);
                if (waitingTasks.size() > 0) {
                    Task task = (Task) waitingTasks.remove(waitingTasks.size() - 1);
                    startTask(task);
        } else {
            discard(pPoolable);
  /** Starts a task immediately.
   * @param pTask The task being started.
   * @return True, if the task could be started immediately. False, if
   * the maxmimum number of concurrent tasks was exceeded. If so, you
   * might consider to use the {@link #addTask(ThreadPool.Task)} method instead.
  public synchronized boolean startTask(Task pTask) {
    if (maxSize != 0  &&  runningThreads.size() >= maxSize) {
      return false;
        Poolable poolable;
    if (waitingThreads.size() > 0) {
        poolable = (Poolable) waitingThreads.remove(waitingThreads.size()-1);
    } else {
            poolable = new Poolable(threadGroup, num++);
    runningThreads.add(poolable);
        poolable.start(pTask);
    return true;
  /** Adds a task for immediate or deferred execution.
   * @param pTask The task being added.
   * @return True, if the task was started immediately. False, if
   * the task will be executed later.
  public synchronized boolean addTask(Task pTask) {
    if (startTask(pTask)) {
      return true;
    waitingTasks.add(pTask);
    return false;
  /** Closes the pool.
  public synchronized void shutdown() {
        while (!waitingThreads.isEmpty()) {
            Poolable poolable = (Poolable) waitingThreads.remove(waitingThreads.size()-1);
            poolable.shutdown();
        while (!runningThreads.isEmpty()) {
            Poolable poolable = (Poolable) runningThreads.remove(runningThreads.size()-1);
            poolable.shutdown();
  /** Returns the maximum number of concurrent threads.
   * @return Maximum number of threads.
  public int getMaxThreads() { return maxSize; }
  /** Returns the number of threads, which have actually been created,
     * as opposed to the number of currently running threads.
    public synchronized int getNumThreads() { return num; }
}

Sounds like you should read up on the [java tutorials |http://java.sun.com/docs/books/tutorial/essential/concurrency/] on threading.
I found some car parts that will help me drive. And no, I don't know how to put them together to make a car. But I want to drive on the highway! I found some car parts that can do this.

Similar Messages

  • Working with threads on a Service

    Hi Gurus,
    I am building a service and I want to run several threads on it, and the number of threads will be customized in the component properties file.
    I am thinking on doing a method that will read that property (threadsToRun) and it will create as many threads as I need, but I am not sure if ATG does have something similar to this already out of the box.
    This is what I have in mind, but it can be a better way to do this.
         public class SubmitOrdersService extends GenericService {
              private int threadsToRun;
              public int getThreadsToRun() {
                   return threadsToRun;
              public void setThreadsToRun(int threadsToRun) {
                   this.threadsToRun = threadsToRun;
              public void startService() {
                   for (int i = 0; i < getThreadsToRun(); i++) {
                        (new SubmitOrdersThread()).start();
              public void submitOrders() {
              public class SubmitOrdersThread extends Thread {
                   public void run() {
                        submitOrders();
    Regards,
    Obed

    I am thinking on doing a method that will read that property (threadsToRun) and it will create as many threads as I need, but I am not sure if ATG does have something similar to this already out of the box.I do not think that ATG will have such functionality, because it is not framework specific but a core concept and logic above, you can use.
    But would you like to share that why do you want to limit number of threads?
    -RMishra

  • EOF Exception with Thread interrupts ?

    EOF file Exception for RandomAccess.readFully() call. All the parameters are valid.
    Is it possible/Any one seen to get EOF exception If another Thread interrupt the thread
    which is doing I/O(READ).
    I am running on SUN jdk131/Solaris8?
    Thanks
    -suresht

    Hint if working with threads on reading data from files just synchronize the methods, like
    public synchronized readData(...){...}
    if you do not do that a thread is reading and when it breaks down it will locks the method(in your case the file will not been closed and if a file is not closed it cannot be opened by another thread/method/object/whatever)

  • Hi all, i can't sync over wifi between my iPhone 4 and Windows 7 64 bit, wifi sync works with the same phone and my Windows 8 machine, tried solutions from other threads with no luck, just thought i'd see if anyone else had any ideas, thanks.

    Hi all, i can't sync over wifi between my iPhone 4 and Windows 7 64 bit, wifi sync works with the same phone and my Windows 8 machine so the problem seems confined to Windows 7. I've tried solutions from other threads -
    Making sure everything is allowed through firewall
    Rebooting phone/laptop/router
    Disabling ipv6
    Disabling all networks except the one curently on
    Re-installing iTunes
    Restoring iPhone
    No luck with any of those unfortunately so i just thought i'd see if anyone else is still without wifi sync after trying those as well and if you ever found a fix, thanks.

    I just wanted to leave a note that it's working now. I'm not sure if it was the latest iTunes update that got it working or that i decided to start a new library instead of using the one i had backed up on Windows 8 (it didn't occur to me to check using the old library when i re-installed iTunes). But if anyone is having this problem, it might be worth trying again with a new installation of iTunes to see if the latest update works for you, and if not, try using a fresh library instead of a backup (by fresh library i mean discard your old library completely and start a new library, not just restore as new iPhone, a whole new library).

  • Is is possible to work work with Java Threads ind WDJ 04s ?

    Hi experts,
    it is possible to work with treads in wdj 04s? I want to reder the ui in one therad and another one should read the data from serveral webservices! After all webservice cals are finished the data should be shown on the ui.
    Example:
    1. User start process -> User see the UI and a progressbar
    2. In background the wervice get the data
    3. User see the improvement
    How it is possible?
    It ist not possible withe the progress bar ui element because I always lost one second between the calls....

    Basically, you shouldn't use threads in any Application Server, since the environment is not thread-safe.
    I think there's a scheduler API in NW that would fit you best. Create your "task" as a scheduled task, happening once, and query this task using some sort of TimerTrigger.
    Would be a way easier if WDP was a bit more advanced, at least I don't see an easy way for you to do that.
    One way running J2EE 1.4 would be the use of ejbTimeout.
    Hope it helps,
    Daniel
    Edited by: Daniel Ruiz on Dec 3, 2009 2:24 PM

  • I just spent an hour composing a reply in a thread ("Firefox will not work with paypal"), only to see "You don't have permission" at Submit - total loss!

    I was logged in to reply in the thread "Firefox will not work with paypal". I spent the better part of an hour carefully composing that reply, testing cases, providing links, etc... [Hint: Firefox, unlike other browsers, has a problem with scripts from server paypalobjects.com.] Because I had taken so long to compose the reply, it seemed like a good idea to check it via the Preview button, but I got a message that that function was not available. Of course I decided to submit it anyway, but when I hit "Submit" I got a message "You don't have permission ..." - at which point I was (stupidly) on a different page with that message, and everything I had composed was gone!

    It might be too late for this, but it's what I use when this happens. Prepare for deep nerdom:
    * Open the web console below the error page by pressing Ctrl+Shift+k
    * Right-click the blank area and turn on logging of the request and response bodies
    * Resubmit the request by clicking the reload button
    * Click the new URL that appears to open the viewer showing the headers and bodies
    There you may be able to copy out the content of your post from the Request Body. You can use a word processor or text editor to find/replace the + characters back to spaces.

  • Problem with threads within applet

    Hello,
    I got an applet, inside this applet I have a singleton, inside this singleton I have a thread.
    this thread is running in endless loop.
    he is doing something and go to sleep on and on.
    the problem is,
    when I refresh my IE6 browser I see more than 1 thread.
    for debug matter, I did the following things:
    inside the thread, sysout every time he goes to sleep.
    sysout in the singleton constructor.
    sysout in the singleton destructor.
    the output goes like this:
    when refresh the page, the singleton constructor loading but not every refresh, sometimes I see the constructor output and sometimes I dont.
    The thread inside the singleton is giving me the same output, sometime I see more than one thread at a time and sometimes I dont.
    The destructor never works (no output there).
    I don't understand what is going on.
    someone can please shed some light?
    thanks.
    btw. I am working with JRE 1.1
    this is very old and big applet and I can't convert it to something new.

    Ooops. sorry!
    I did.
         public void start() {
         public void stop() {
         public void destroy() {
              try {
                   resetAll();
                   Configuration.closeConnection();
                   QuoteItem.closeConnection();
              } finally {
                   try {
                        super.finalize();
                   } catch (Throwable e) {
                        e.printStackTrace();
         }

  • IP Phone No Longer Working with FiOS

    For almost 5 years, we had a Mitel 5020 IP Phone Handest that we used for working from home.  The phone plugged directly into a 4 port Netgear router which in turn was connected to a Linksys Cable modem.  Comcast was the ISP.  The phone worked perfectly in connecting with the remote PBX.
    We moved to VZN FiOS one month ago and the phone has not worked since the new service was installed.  We followed the reset instructions for the phone and even returned it to the home office for testing.  The phone work perfectly in the office.
    The company telecom/IT support is hit & miss:  they returned the handset to us and kinda left us on our own to resolve the problem.
    We have a Westell Ultraline Series 3  9100EM router now.  The phone has been connected directly to the back of the router via ethernet cable.  I can ping the phone and ping the PBX from the router; but the PBX and phone no longer connect (although IT states that the PBX server sees the device).
    Is this a port forwarding issue?  If not, what other router settings should I check?
    I really enjoy the FiOS speed and the rest of the networked devices have all worked flawlessly since the conversion - even a flakey print server.
    Any thoughts? 

    gilbo72 wrote:
    Did anyone fix this issue.  I have a Mitel 5224 my new company sent me and it does not work with my 9100em router.  I tried it at my son's house and it worked fine using a Linksys router connected to a motorola cable modem.  
    I believe golfforlong's problems were resolved with one of the suggestions in this thread:
    http://www.dslreports.com/forum/r22074647-northwes​t-Mitel-Teleworker-5020-No-Longer-Connects-over-Fi​...
    Give those suggestions a try and post back if they don't work.

  • Photoshop CC: program error occures when working with videos

    Whenever I'm trying to trim a video in Photoshop CC I'm running into this error:
    "Could not complete your request because of a program error"
    I can't close it by clicking "okay", so I have to close photoshop via task manager.
    - I also came across this error when I was trying to duplicate a text layer while working with a video.
    - When I was using Photoshop CS6 several months ago trimming videos worked fine.
    - I've tested if the problem appears on my laptop (Win7, i5, on board intel hd graphics) in Photoshop CC, and it does not!
    - I've deinstalled all Adobe Products (and their plugins) and ran Adobe Creative Cloud Cleaner without any errors, then reinstalled Photoshop CC.
    - I restored my preferences.
    - My graphic board drivers are up to date.
    - My computer is a Windows 7 (64 bit) Home Premium, Intel Core i7-2600 CPU @ 3.40 GHz,  16 GB RAM with a NVIDIA GeForce GT 520 graphic board.
    I honestly don't know what's the matter. Unfortunately I couldn't find any other thread with the same problem.
    Hope you'll be able to help
    Thanks in advance!

    OK.  I suspect you might have run into one of the Mavericks bugs then.  I would certainly expect your system to handle 720 without complaining.
    Apparently Adobe have made Apple aware of these bugs, and have no more control over rectifying them.
    Try Google with 'Photoshop cc video Mavericks'
    http://forums.adobe.com/message/5826052
    I am not aware of any workarounds, but I use a PC and use PremPro for video anyway, but that's not to say there isn't one.  If this thread doesn't bring you an answer, start a new one with a subject line something like:
    Video Editing Problems with CC and Mavericks

  • How do I get my MacBook Air webcam to work with Skype?

    When I make a call on skype the other party cannot see me but I can see them. Under Preferences on Skype there is no recognised camer either. How do I get my webcam to communicate with Skype?

    See this thread:
    https://discussions.apple.com/thread/5306216?tstart=0
    FIX:
    1. You need Time Machine
    2. Go to folder /Library/CoreMediaIO/Plug-Ins/DAL/
    3. Copy AppleCamera.plugin to good place (usb memory stick is the best place).
    4. Go to Time machine in date that skype work fine.
    5. Change AppleCamera.plugin with file from Time Machine
    6. Restart system, Now skype need to work with camera.
    From Apple:
    MacBook Air (Mid 2013): FaceTime HD Camera might not work after OS X 10.8.5 update

  • Flash player does not work with Ie or Firefox with win 8.1?

    Flash player does not work with Ie or Firefox with win 8.1 64, If i try and play a video I get the message to install Flashplayer.
    If I try and install it it says it is already installed. Your onsite  installer says it is not applicable to my machine.
    I have followed all the normal steps re enabling addons and active filters etc.
    all to no avail Pc is Dell 6 months old, Flashplayer has never worked on this machine. Last MS update mid Dec 2014.
    Version of flashplayer is 15....03.......

    Flash Player is a built-in component of Internet Explorer.  There's nothing separate to download or install.
    Firefox requires a different version of Flash Player (the NPAPI plug-in), which will be served to you if you go here: http://get.adobe.com/flashplayer using Firefox; however, there are some unique stability issues related to Firefox on Win8.1, and you're probably better off using Google Chrome if you want a more optimal experience with Flash Player.
    For problems where IE isn't being detected by sites that require Flash:
    First, confirm that ActiveX Filtering is configured to allow Flash content:
    https://forums.adobe.com/thread/867968
    Internet Explorer 11 introduces a number of changes both to how the browser identifies itself to remote web servers, and to how it processes JavaScript intended to target behaviors specific to Internet Explorer. Unfortunately, this means that content on some sites will be broken until the content provider changes their site to conform to the new development approach required by modern versions of IE.
    You can try to work around these issues by using Compatibility View:
    http://windows.microsoft.com/en-us/internet-explorer/use-compatibility-view#ie=ie-11

  • HDMI output not working with AT200 under ICS

    Hello
    The HDMI output of my tablet AT200 doesn't work with any TV set.
    My AT 200 tablet is under ICS.
    I tried both HDMI configurations : full screen and video window. No effect at all.
    I have red the post of denis48 and the response of MasterG and tried his propositions with no success
    Is there somebody to help me please ?

    Hi
    I think you meant this thread:
    http://forums.computers.toshiba-europe.com/forums/thread.jspa?threadID=67654
    The output should work as its described in the posting.
    If it does not work, reset the tablet settings and try again

  • Software that Works with TV@nywhere

    I'd like to hear from others as to what their experiences have been with 3rd party software using the TV@nywhere card. This information may help others who also own this card and would like to experiment with different software.
    I own the TV@nywhere Master card, here is my experience with the software listed below. Some of this software can be trained to use the remote control with the program GIRDER. I rely on GIRDER for use with MSIPVS, PowerDVD, and Showshifter.
    MSIPVS (WINDVR2) and FM Radio - Work very well. However, recorded shows (no matter what format they are recorded in) have a slight slur in the audio where the levels go slightly up and down. Also, timeshifting often causes sync problems between video and audio. The audio is just NOT steady and stable. Picture quality is very good. Not terribly flexible in recording formats. MPEG-4 support is there but it really sucks and can't be tweaked.
    WinDVR3 - Unfortunately this software cannot tune my channels. When it tries to autoscan, it holds the channel for 2 seconds and drops it. This program is unusable. The remote control also does not work with this program; although I've heard there is a workaround for the remote where you can copy files from MSIPVS into the WinDVR3 folder.
    Cyberlink PowerVCR - Excellent picture and audio. However, recorded shows have poor audio with pops and hisses. Timeshifting also can have some sync problems. Remote control doesn't work with this program either. Not very flexible with different recording formats.
    Snapstream BeyondTV 3 - Wow, very cool package. Even has a built in channel guide that can be used in Canada. Groovy graphics, setup and options. But oh my god the picture quality totally SUCKS. The tv channels are murky and saturated and no degree of tweaking makes any difference. This program is proof that a slick package means nothing without the TV Quality to back it up.
    Showshifter - Showshifter has some great options. It also has excellent audio and video quality. The only downfall with this program is that it uses Windows task scheduler to schedule recorded shows. As a result, many recordings don't work or disappear after they've been saved. If this program had a built in scheduler such as PowerVCR or WinDVD, it would be a terrific solution. On the other hand, if you don't record shows all the time, this is an excellent solution for the TV@nywhere card. It allows recordings to be created in VCD, DVD, SVCD, AVI (Divx), etc. etc. Excellent options. The program generally keeps CPU usage between 13-20% and the recording quality is superb. If you install Girder, you can even use your remote control with this program by adding the appropriate group.
    IUVCR - works ok but is nothing pretty to look at. Scheduler also uses Windows task scheduler which is unreliable. Can be set up to use DIVX for recordings, etc. Functional, but not the best of the best.
    SageTV - forget this program, didn't even recognize my TV Tuner Card.
    Fly2000TV - Another program that I played with for several hours but couldn't get it to recognize my TV Tuner Card.
    Hopefully this information will help some of you who are seeking other software solutions. If I've missed some compatible software packages, I'd be very grateful if others of you would add to this thread and provide detailed information as to your experiences.
    Thanks
    TVeith

    Quote
    Originally posted by tveith
    Sorry for the late response.
    1 - No, I did not need to do this workaround for MSIPVS. It worked fine when set to Canada. This is obvously due to the deal MSI arranged with Intervideo.
    2 - No I never had to uninstall/reinstall to get it to work, it worked the first time I tried it.
    Have you given Showshifter a try yet? It is the only program I've come across that has been 100% reliable with the MSI TV@nywhere card. Not to mention that it has a Show Guide capability. I should mention that I purchased the program last week and the support I've received has been outstanding.
    TVeith
    I tried Showshifter but I found on my system, it was not removing the interlacing, which was annoying. With my current uncertainty of whether or not the MSI card is working normal, I can't say that that problem is not unique to my setup.
    The current state of my card is that, after all the jerking around I had to do to try to determine the cause of the MSIPVS freeze up, the card no longer allows itself to be setup. It no longer accepts country location, or cable signal source but always reverts back to Afghanistan and antenna. This prevents a cable scan from taking place and I am no longer able to tune any stations. I can therefore do no more testing to try to determine cause of the original program freezing problem. I don't believe that any tv tuner program using the Windows drivers will work with this card now. I would have concluded that finally the card has bit the dust except for the fact that I can use an alpha version of Dscaler to control the tuner and tune all the appropriate stations on my cable hookup. I am working with the developers to add sound support for this card to the program. The unique aspect of Dscaler is that it controls the card directly instead of using the Windows drivers. Unfortunately, or fortunately, depending on how you look at it, the next version (5) being developed will use the Windows drivers.

  • Sharepoint list dataheet view error "Cannot connect to the server at this time. You can continue working with this list, but some data may not be available"

    I have a List which is having around 14000 items in it.while opening that list in datasheet view it is giving error .
    Below is a summary of the issue:
    After selecting datasheet view beow error occurs:
        "Cannot connect to the server at this time.  You can continue working with this list, but some data may not be available."
        "Unable to retrieve all data."
        The item counts displays say 100 out of 14000 items.
    Exporting List to excel is giving only 2000 records out of 14000 records.
    Other Observations   -  
    This is happening to only one list on the site .There are other lists in the site whose no. of records is equal to 8000 to 9000.They are working absolutely fine without any error.
    Also, If I am saving this list as a template and creating another list with it ,then it is working absolutely fine with 14000 records,so the issue does not seem to be related with no. of records as the template list is working fine.
    I have checked the Alternate access mapping setting ,its fine.
    It should not be related to lookup,datefield or any other column as the list created from it template is working fine with all these columns.
    I checked below links also ,but doesn't seem to work in my case.
    http://social.technet.microsoft.com/forums/en-US/sharepointadminprevious/thread/974b9168-f548-409b-a7f9-a79b9fdd4c50/
    http://social.technet.microsoft.com/Forums/en-US/smallbusinessserver/thread/87077dd8-a329-48e8-b42d-d0a8bf87b082
    http://social.msdn.microsoft.com/Forums/en-US/sharepointgeneral/thread/dc757598-f670-4229-9f8a-07656346b9b0

    I have spent two days to resolve this issue. Microsoft has released two KBs with reference to this issue...but are not appearing in search results at the top.
    I am sharing my finding.
    1. First install the
    KB2552989 (Hopefully you might have already installed it. The KB detetcts it and informs the user.)
    2. Then update registry by adding new key for data fetch timeout as mentioned inKB2553007
    These two steps resolved the issue in our environment. Hope it might help others as well.
    Pradip T. ------------- MCTS(SharePoint 2010/Web)|MCPD(Web Development) https://www.mcpvirtualbusinesscard.com/VBCServer/paddytakate/profile

  • Problem with Thread and InputStream

    Hi,
    I am having a problem with threads and InputStreams. I have a class which
    extends Thread. I have created and started four instances of this class. But
    only one instance finishes its' work. When I check the state of other three
    threads their state remains Runnable.
    What I want to do is to open four InputStreams which are running in four
    threads, which reads from the same url.
    This is what I have written in my thread class's run method,
    public void run()
         URL url = new URL("http://localhost/test/myFile.exe");
    URLConnection conn = url.openConnection();
    InputStream istream = conn.getInputStream();
    System.out.println("input stream taken");
    If I close the input stream at the end of the run method, then other threads
    also works fine. But I do not want to close it becuase I have to read data
    from it later.
    The file(myFile.exe) I am trying to read is about 35 MB in size.
    When I try to read a file which is about 10 KB all the threads work well.
    Plz teach me how to solve this problem.
    I am using JDK 1.5 and Win XP home edition.
    Thanks in advance,
    Chamal.

    I dunno if we should be doing such things as this code does, but it works fine for me. All threads get completed.
    public class ThreadURL implements Runnable
        /* (non-Javadoc)
         * @see java.lang.Runnable#run()
        public void run()
            try
                URL url = new URL("http://localhost:7777/java/install/");
                URLConnection conn = url.openConnection();
                InputStream istream = conn.getInputStream();
                System.out.println("input stream taken by "+Thread.currentThread().getName());
                istream.close();
                System.out.println("input stream closed by "+Thread.currentThread().getName());
            catch (MalformedURLException e)
                System.out.println(e);
                //TODO Handle exception.
            catch (IOException e)
                System.out.println(e);
                //TODO Handle exception.
        public static void main(String[] args)
            ThreadURL u = new ThreadURL();
            Thread t = new Thread(u,"1");
            Thread t1 = new Thread(u,"2");
            Thread t2 = new Thread(u,"3");
            Thread t3 = new Thread(u,"4");
            t.start();
            t1.start();
            t2.start();
            t3.start();
    }And this is the o/p i got
    input stream taken by 2
    input stream closed by 2
    input stream taken by 4
    input stream closed by 4
    input stream taken by 3
    input stream closed by 3
    input stream taken by 1
    input stream closed by 1
    can u paste your whole code ?
    ram.

Maybe you are looking for

  • F-02 with asset retirement: Trans. type not possible - No affil. company

    Hello Gurus, I am struggling with the following, I hope you can help me: We want to sell an investment using a trading partner. When entering the asset retirement transaction type 230, I get error message AA 389 Trans. type not possible (No affiliate

  • MBAM 1.0 and Windows 8.1

    Hello, Is it possible and supported to install MBAM 1.0 on Windows 8.1 Enterprise? Thanks, Nick.

  • LR may require PS Cam Raw plug-in v 8.5 for compatibility

    I get the msg "this version of Lightroom may require the Photoshop camera raw plug-in version 8.5 for full compatibility" I have updated ACR, LR and PS.  Removed older version of PS (Now at 2014 release, 20140508.r.58 x64) on macbook pro, OS X. How d

  • IPad virus?

    Interesting thing occurring on my iPad. If I open a new tab in safari or open a link on a page, it goes to the wanted page. But then switches to a graphic saying something about "someone doesn't like you, and you f**ked up" it then goes to a website,

  • Light Room import site info from Dreamweaver.

    What is the best way to upload a lightroom gallery? directly to the website or export it to the folder where Dreamweaver stores the site and then Sync?