Problem with threads, program always crash

new to threads, may be doing something COMPLETELY wrong. When I run the program I get a couple of NullPointerExceptions in Thread-0 and Thread-1. I'm confused because it screws up when I call size() for arrayList, and in the API size doesn't throw anything.
public class ProducerConsumerRunner
   public static void main(String args[])
      Queue q = new Queue(QUEUE_MAX_SIZE);
      ProducerRunnable producer = new ProducerRunnable(q, ITERATIONS);
      ConsumerRunnable consumer = new ConsumerRunnable(q, ITERATIONS);
      //works good up to here
      Thread t1 = new Thread(producer);
      Thread t2 = new Thread(consumer);
      t1.start();
      t2.start();
   private static int ITERATIONS = 50;
   private static int QUEUE_MAX_SIZE = 25;
import java.util.ArrayList;
import java.util.concurrent.locks.ReentrantLock;
public class Queue {
     public Queue(int maxSize)
          list = new ReentrantLock();
          underLimit = list.newCondition();
          MAX_SIZE = maxSize;
     public void add(String line)
          list.lock();
          try{
                       System.out.println("add method of Queue");
               while(record.size() >= MAX_SIZE){//things get screwed up when this condition is evaluated
                    //size method is crashing the program
                    System.out.println("2");
                    underLimit.await();
                    System.out.println("3");
               record.add(line);
          }catch(java.lang.InterruptedException e){
               System.out.println("await interupted: "+e.getMessage());
          }finally{
               list.unlock();
     public void remove(int line)
          list.lock();
          record.remove(line);
          list.unlock();
     public  ArrayList<String> record;
     private final ReentrantLock list;
     private final java.util.concurrent.locks.Condition underLimit;
     private final int MAX_SIZE;
import java.util.Date;
public class ProducerRunnable implements Runnable{
     public ProducerRunnable(Queue q, int itterations)
          this.q = q;
          ITTERATIONS = itterations;
     public void run()
          String date;
          for(int i = 0; i<ITTERATIONS; i++)
               date = new Date().toString();
               q.add(date);//this is where it screws up
               System.out.println(date+" added");
               try{
               Thread.sleep(100);
               }catch(java.lang.InterruptedException e){
                    System.out.println("ProduccerRunnable's sleep was interupted");
     private final Queue q;
     private final int ITTERATIONS;
public class ConsumerRunnable implements Runnable{
     public ConsumerRunnable(Queue q, int itterations)
          this.q = q;
          ITTERATIONS = itterations;
     public void run()
          //Queue q = new Queue();
          int length;
          for(int i = 0; i<ITTERATIONS; i++)
               length = q.record.size();//things are getting screwed up here
               while(q.record.get(length) == null)
                    length--;
               System.out.println((String)q.record.get(length));
               q.remove(length);
               try{
               Thread.sleep(100);
               }catch(java.lang.InterruptedException e){
                    System.out.println("ConsumerRunnable's sleep was interupted");
     private final Queue q;
     private final int ITTERATIONS;
}

question:
this works right
     public void remove()
          list.lock();
          int line = 0;
          try{
               *while(record.size() < 1)*
                    range.await();
               record.remove(line);
               range.signalAll();
          }catch(java.lang.InterruptedException e){
               System.out.println("await interupted: "+e.getMessage());
          }finally{
               list.unlock();
     }this is deadlock
*int list = 0;*
*while((list = record.size)<1) was screwing things up because of the assignment*record is ArrayList of strings. when better to use Vector instead of ArrayList? i notice no differnce and i use threads
initially I thought record.size was being evaluated and before could be assigned to list, time slice ran out. this could not be case because I use ReentrantLock (list) to lock it.
Edited by: bean-planet on Apr 1, 2009 4:31 PM

Similar Messages

  • Is anyone having problems with the program MacKeeper not runing a full scan in Mavericks?

    Is anyone having problems with the program MacKeeper not runing a full scan in Mavericks?

    Do not install MacKeeper (and how to uninstall it if you have):
    https://discussions.apple.com/docs/DOC-6221
    by Klaus1
    (Please note that references to the original developers, Zeobit, also now refer to Kromtech Alliance Corp, who acquired MacKeeper and PCKeeper from ZeoBit LLC in early 2013.
    And Here  >  Beware MacKeeper
    In General 3rd Party AV Software is Not Required as Mac OS X tends to look after itself.
    Read Here  > https://discussions.apple.com/thread/4545776?tstart=0
    See Here  >  Antivirus Discussion

  • 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.

  • Problem with the program symbols in quality

    Dear all,
    I am facing a problem with the program symbols.
    I have added new global fields in development, i have called those definations in text names. It is working fine.
    After transporting these  program changes in to quality these new global definations are not displaying in quality and varibles are not working.
    Please give me some suggestion.
    Thanks and advance

    Hi Chandra,
    Please check the following.....
    (1)The transport request status in se10 and see if has been successfully imported to QA..
    (2)if all the declarations or code have been collected in a Transport and not saved as temporary objects
    To confirm the same we have to compare the code in quality and development and see if they are the same
    Pls check and revert
    Regards
    Byju

  • Labview Program always crashs after a few hour' work

    My Labview Program always crashs after a few hour' work. The error report is:
    #Date: 2014年7月30日 4:27:27
    #OSName: Windows 7 Ultimate
    #OSVers: 6.1
    #OSBuild: 7600
    #AppName:
    #Version: 12.0 32-bit
    #AppKind: AppLib
    #AppModDate: 07/29/2014 20:13 GMT
    #LabVIEW Base Address: 0x30000000
    <DEBUG_OUTPUT>
    2014/7/30 8:34:11.006
    DAbort 0xF50EFD7B:
    c:\builds\penguin\labview\components\mgcore\trunk\12.0\source\MemoryManager.cpp(1104) : DAbort 0xF50EFD7B:
    minidump id: 6ebe0400-78d2-41e3-b2fd-858c21e3567b
    $Id: //labview/components/mgcore/trunk/12.0/source/MemoryManager.cpp#13 $
    </DEBUG_OUTPUT>
    0x30076B23 - lvrt <unknown> + 0
    0x307D1F90 - lvrt <unknown> + 0
    0x30605C66 - lvrt <unknown> + 0
    0x6C42A045 - nivissvc <unknown> + 0
    0x075A1F00 - nivision <unknown> + 0
    0x03B0577A - <unknown> <unknown> + 0
    0xE5BA0800 - <unknown> <unknown> + 0
    Who knows what had happened? Thank you for your help.

    Thank you for your reply.
    I don't build array continuously. I just build a few queues. I am sorry the program is too large to show it to you. I have read the dump file. It seems like memory overflow. Do you think so? But it seems like there is no chance for memory overflow in Labview. The dump file is as below:
    Microsoft (R) Windows Debugger Version 6.3.9600.17029 X86
    Copyright (c) Microsoft Corporation. All rights reserved.
    Loading Dump File [D:\LabVIEW Data\LVInternalReports\1.0.0.1\51437f73-aab6-4097-b7e1-3fee8a74e4dd\6ebe0400-78d2-41e3-b2fd-858c21e3567b.dmp]
    User Mini Dump File: Only registers, stack and portions of memory are available
    ************* Symbol Path validation summary **************
    Response Time (ms) Location
    OK C:\Program Files (x86)\Symbols
    Symbol search path is: C:\Program Files (x86)\Symbols
    Executable search path is:
    Windows 7 Version 7600 MP (4 procs) Free x86 compatible
    Product: WinNt, suite: SingleUserTS
    Machine Name:
    Debug session time: Wed Jul 30 08:34:10.000 2014 (UTC + 8:00)
    System Uptime: not available
    Process Uptime: 0 days 4:06:44.000
    This dump file has an exception of interest stored in it.
    The stored exception information can be accessed via .ecxr.
    (dfc.4b8): Unknown exception - code 00000002 (first/second chance not available)
    *** WARNING: Unable to verify timestamp for ntdll.dll
    *** ERROR: Module load completed but symbols could not be loaded for ntdll.dll
    *** WARNING: Unable to verify timestamp for kernel32.dll
    *** ERROR: Module load completed but symbols could not be loaded for kernel32.dll
    eax=13dbec20 ebx=13dbe550 ecx=00000008 edx=00000008 esi=00000003 edi=13dbe570
    eip=77b564f4 esp=13dbe500 ebp=13dbe59c iopl=0 nv up ei pl zr na pe nc
    cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
    ntdll+0x464f4:
    77b564f4 c3 ret

  • I installed Adobe CS6 Design & Web Premium on my Mac Book Pro a few years ago but have repeatedly encountered problems with the programs freezing or not opening properly. It's a Student and Teacher Licensing version so an academic ID is required but I am

    I installed Adobe CS6 Design & Web Premium on my Mac Book Pro a few years ago but have repeatedly encountered problems with the programs freezing or not opening properly. It's a Student and Teacher Licensing version so an academic ID is required but I am no longer a student--can I still reinstall it since my academic ID may no longer be valid?

    Erin Elzo as long as the serial number has been registered under your account at http://www.adobe.com/ then you should be able to continue to utilize the software.  You can find details on how to locate your registered serial number at Find your serial number quickly - http://helpx.adobe.com/x-productkb/global/find-serial-number.html.

  • Problem with various programs freezing/not working

    I'm not sure if it's a problem with the computer itself or with the software, but perhaps someone on here can help me.
    For about a week now I've been having problems with various programs on my iMac. These programs include iTunes, Force Quit, Shut Down, Safari, Finder, and certain functions on the keyboard.
    The problems I've been having revolve around the programs freezing up when you either first try to operate them or after opening the programs and trying to click on things within the program itself.
    A good example: I haven't been able to use iTunes past the point of opening it up. Once I try to play a song, it freezes up and the rainbow wheel comes up and just keeps on spinning for eternity, or until I manually reboot the computer via the power button.
    The volume controls on the keyboard don't work at all. When I first boot up the computer, I can press a volume button and the symbol will appear on the screen, but the level won't move up or down and if you press it again after that disappears then it doesn't reappear.
    Force Quit and other applications tend to stay on the screen after you click the quit button or other end/cancel button and won't go away until iMac is rebooted manually by button on back.
    Safari gets stuck on occasion depending on which site I go to. It happened once when I went to MySpace.com, but only cos of one of the flash sites they were advertising. I went to the same site an hour later and it was fine since it was advertising something else. I have a job site I can't access because when I click on the 'jobs' link to look for a job, it gets 3/4 of the way through the upload and freezes.
    And right now I can't tell you which model I have since I can't access the 'About This Mac' info, other than to tell you it's the 20" with 320 GB with Leopard software, Mac OS X v10.5. It gets regular updates.
    So... if there's anyone who could help me, I would greatly appreciate it.
    Please note, I don't have Apple Care since I can't afford it yet, and I just bought my computer in October 2007. Thanks!

    Start with http://www.thexlab.com/faqs/multipleappsquit.html

  • MBP with retina display always crash when using Final cut pro x and iMovie. Plz l need help

    HI, My MBP with retina display always crash when l am using Final cut pro x and iMovie and come up with gray screen. Plz l need help

    Take it back and get a refund. What are you waiting for, your new Mac does not work correctly.

  • HT201487 i have a problem with xcode programming app when i lunch to it it asking me to enter my password and when i enter it the program show that it is wrong but am 100% sure it's wright so please help me with this issue thanks

    i have a problem with xcode programming app when i lunch to it it asking me to enter my password and when i enter it the program show that it is wrong but am 100% sure it's wright so please help me with this issue thanks

    That's not very intuitive
    Check your mail server setup (mail>preferences>accounts>) choose your MobileMe account and select Outgoing Mail Server (SMTP) dropdown box, select Edit SMTP server list, verify that each instance of the me server has a password, if there are more than one and you only have one account then delete the one without a password.

  • I have a problem with the program Lightroom on Mac

    Hello!
    I have a problem with the program Lightroom on Mac
    Today set a new Lightroom CC 2015 through Creative Cloud but it does not run , I do not know what is the reason
    Please help resolve this issue as soon as possible , I can not continue its work
    Thank you for attention

    Hi Musik
    Take a look at this link and see if it helps:
    Lightroom doesn't launch or quits automatically after splash screen
    Pattie

  • Hello! Help me please, I have a problem with the program occurred after the upgrade to version 3. 6. 16, namely by pressing the button 'Open a new tab' nothing happens. ?

    Hello! Help me please, I have a problem with the program occurred after the upgrade to version 3. 6. 16, namely by pressing the button 'Open a new tab' nothing happens. ?

    This issue can be caused by the Ask<i></i>.com toolbar (Tools > Add-ons > Extensions)
    See:
    * [[Troubleshooting extensions and themes]]

  • Has anyone been having problems with camera, safari etc. crashing on iOS 5.0.1 because I have been having the problem as well as my brother I have the iPhone 4. If anyone else having same issue comment below

    Has anyone been having problems with camera, safari etc. crashing on iOS 5.0.1 because I have been having the problem as well as my brother I have the iPhone 4. If anyone else having same issue comment below

    Then the next step would be a restore as new to rule out corruption in the backup.

  • Problems with audio programs after update to Maverics

    After updating to Mavericks on my Mac Mini there is problem with audio programs. I cant open iTunes at all, I click it and it disappear in a second. Also when I press play in GuitarPro 6 or in Vox player nothing happens. It just wont start playing. I really dont like this update.. and my mac is slower now. I cant downgrade my system back so this is really frustrating to me as a musician.

    I have the same problem with my Conceptronic CH3HNAS and have found a free and easy solution.
    Since a lot of people report they are able to access their NAS using apps other than the Finder itself, I decided to look for a free Lion-compatible File Manager to use instead of Finder.
    I have found muCommander ( http://www.mucommander.com/ ) and indeed it works fine. All I did was click on the button highlighted bellow, go to "bonjour services" and select my NAS. It prompted me for my username and password and voilá, it works fine.
    I keep Finder for everyday use and just load muCommander when I want to access the NAS. At least now I don't have to start my WinXP VM anymore just to access it.
    Hope it helps you.

  • Can't upload photos to Flickr with Safari - Safari always crashes.

    Help, I can't upload photos to Flickr with Safari.  Safari always crashes and I recieve the following error message (and I've not included all of it just to keep it somewhat short):
    Process:         com.apple.WebKit.WebContent [673]
    Path:            /System/Library/PrivateFrameworks/WebKit2.framework/Versions/A/XPCServices/com. apple.WebKit.WebContent.xpc/Contents/MacOS/com.apple.WebKit.WebContent
    Identifier:      com.apple.WebKit.WebContent
    Version:         9537 (9537.74.9)
    Build Info:      WebKit2-7537074009000000~3
    Code Type:       X86-64 (Native)
    Parent Process:  ??? [1]
    Responsible:     Safari [155]
    User ID:         501
    Date/Time:       2014-03-17 22:17:24.605 -0500
    OS Version:      Mac OS X 10.9.2 (13C64)
    Report Version:  11
    Anonymous UUID:  782BB667-7908-403F-2F7A-8205C11B8B24
    Crashed Thread:  0  Dispatch queue: com.apple.main-thread
    Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
    Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008
    VM Regions Near 0x8:
    -->
        __TEXT                 000000010babf000-000000010bac0000 [    4K] r-x/rwx SM=COW  /System/Library/PrivateFrameworks/WebKit2.framework/Versions/A/XPCServices/com. apple.WebKit.WebContent.xpc/Contents/MacOS/com.apple.WebKit.WebContent
    Application Specific Information:
    Bundle controller class:
    BrowserBundleController
    Process Model:
    Multiple Web Processes
    Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
    0   com.apple.WebKit2                       0x00007fff922c9212 WebKit::SandboxExtension::consumePermanently() + 10
    1   com.apple.WebKit2                       0x00007fff92408c38 WebKit::WebPage::extendSandboxForFileFromOpenPanel(WebKit::SandboxExtension::Ha ndle const&) + 26
    2   com.apple.WebKit2                       0x00007fff9240da8b void CoreIPC::handleMessage<Messages::WebPage::ExtendSandboxForFileFromOpenPanel, WebKit::WebPage, void (WebKit::WebPage::*)(WebKit::SandboxExtension::Handle const&)>(CoreIPC::MessageDecoder&, WebKit::WebPage*, void (WebKit::WebPage::*)(WebKit::SandboxExtension::Handle const&)) + 80
    3   com.apple.WebKit2                       0x00007fff922db338 WebKit::WebPage::didReceiveWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) + 6660
    4   com.apple.WebKit2                       0x00007fff922c3a6b CoreIPC::MessageReceiverMap::dispatchMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) + 125
    5   com.apple.WebKit2                       0x00007fff922c3950 WebKit::WebProcess::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) + 28
    6   com.apple.WebKit2                       0x00007fff922c38b9 CoreIPC::Connection::dispatchMessage(***::PassOwnPtr<CoreIPC::MessageDecoder>) + 101
    7   com.apple.WebKit2                       0x00007fff922c37e2 CoreIPC::Connection::dispatchOneMessage() + 106
    8   com.apple.WebCore                       0x00007fff8eefe34e WebCore::RunLoop::performWork() + 270
    9   com.apple.WebCore                       0x00007fff8eefe222 WebCore::RunLoop::performWork(void*) + 34
    10  com.apple.CoreFoundation                0x00007fff8db9e731 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    11  com.apple.CoreFoundation                0x00007fff8db8fea2 __CFRunLoopDoSources0 + 242
    12  com.apple.CoreFoundation                0x00007fff8db8f62f __CFRunLoopRun + 831
    13  com.apple.CoreFoundation                0x00007fff8db8f0b5 CFRunLoopRunSpecific + 309
    14  com.apple.HIToolbox                     0x00007fff93de1a0d RunCurrentEventLoopInMode + 226
    15  com.apple.HIToolbox                     0x00007fff93de17b7 ReceiveNextEventCommon + 479
    16  com.apple.HIToolbox                     0x00007fff93de15bc _BlockUntilNextEventMatchingListInModeWithFilter + 65
    17  com.apple.AppKit                        0x00007fff8b00b3de _DPSNextEvent + 1434
    18  com.apple.AppKit                        0x00007fff8b00aa2b -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
    19  com.apple.AppKit                        0x00007fff8affeb2c -[NSApplication run] + 553
    20  com.apple.AppKit                        0x00007fff8afe9913 NSApplicationMain + 940
    21  com.apple.XPCService                    0x00007fff96086c0f _xpc_main + 385
    22  libxpc.dylib                            0x00007fff8c819bde xpc_main + 399
    23  com.apple.WebKit.WebContent             0x000000010babfba0 0x10babf000 + 2976
    24  libdyld.dylib                           0x00007fff959895fd start + 1
    Thread 1:: Dispatch queue: com.apple.libdispatch-manager
    0   libsystem_kernel.dylib                  0x00007fff8c8c8662 kevent64 + 10
    1   libdispatch.dylib                       0x00007fff96fe643d _dispatch_mgr_invoke + 239
    2   libdispatch.dylib                       0x00007fff96fe6152 _dispatch_mgr_thread + 52
    Thread 2:
    0   libsystem_kernel.dylib                  0x00007fff8c8c3a1a mach_msg_trap + 10
    1   libsystem_kernel.dylib                  0x00007fff8c8c2d18 mach_msg + 64
    2   com.apple.CoreFoundation                0x00007fff8db90155 __CFRunLoopServiceMachPort + 181
    3   com.apple.CoreFoundation                0x00007fff8db8f779 __CFRunLoopRun + 1161
    4   com.apple.CoreFoundation                0x00007fff8db8f0b5 CFRunLoopRunSpecific + 309
    5   com.apple.AppKit                        0x00007fff8b1ab16e _NSEventThread + 144
    6   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    7   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    8   libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 3:: com.apple.NSURLConnectionLoader
    0   libsystem_kernel.dylib                  0x00007fff8c8c3a1a mach_msg_trap + 10
    1   libsystem_kernel.dylib                  0x00007fff8c8c2d18 mach_msg + 64
    2   com.apple.CoreFoundation                0x00007fff8db90155 __CFRunLoopServiceMachPort + 181
    3   com.apple.CoreFoundation                0x00007fff8db8f779 __CFRunLoopRun + 1161
    4   com.apple.CoreFoundation                0x00007fff8db8f0b5 CFRunLoopRunSpecific + 309
    5   com.apple.Foundation                    0x00007fff946b0967 +[NSURLConnection(Loader) _resourceLoadLoop:] + 348
    6   com.apple.Foundation                    0x00007fff946b076b __NSThread__main__ + 1318
    7   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    8   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    9   libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 4:: WebCore: Scrolling
    0   libsystem_kernel.dylib                  0x00007fff8c8c3a1a mach_msg_trap + 10
    1   libsystem_kernel.dylib                  0x00007fff8c8c2d18 mach_msg + 64
    2   com.apple.CoreFoundation                0x00007fff8db90155 __CFRunLoopServiceMachPort + 181
    3   com.apple.CoreFoundation                0x00007fff8db8f779 __CFRunLoopRun + 1161
    4   com.apple.CoreFoundation                0x00007fff8db8f0b5 CFRunLoopRunSpecific + 309
    5   com.apple.CoreFoundation                0x00007fff8dc44811 CFRunLoopRun + 97
    6   com.apple.WebCore                       0x00007fff8efaad44 WebCore::ScrollingThread::initializeRunLoop() + 244
    7   com.apple.JavaScriptCore                0x00007fff8a82bc5f ***::wtfThreadEntryPoint(void*) + 15
    8   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    9   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    10  libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 5:: JavaScriptCore::BlockFree
    0   libsystem_kernel.dylib                  0x00007fff8c8c7716 __psynch_cvwait + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7fc3b _pthread_cond_wait + 727
    2   com.apple.JavaScriptCore                0x00007fff8a8369c5 JSC::BlockAllocator::blockFreeingThreadMain() + 261
    3   com.apple.JavaScriptCore                0x00007fff8a82bc5f ***::wtfThreadEntryPoint(void*) + 15
    4   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    5   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    6   libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 6:: JavaScriptCore::Marking
    0   libsystem_kernel.dylib                  0x00007fff8c8c7716 __psynch_cvwait + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7fc3b _pthread_cond_wait + 727
    2   com.apple.JavaScriptCore                0x00007fff8a837437 JSC::GCThread::waitForNextPhase() + 119
    3   com.apple.JavaScriptCore                0x00007fff8a8372c8 JSC::GCThread::gcThreadMain() + 88
    4   com.apple.JavaScriptCore                0x00007fff8a82bc5f ***::wtfThreadEntryPoint(void*) + 15
    5   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    6   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    7   libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 7:: JavaScriptCore::Marking
    0   libsystem_kernel.dylib                  0x00007fff8c8c7716 __psynch_cvwait + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7fc3b _pthread_cond_wait + 727
    2   com.apple.JavaScriptCore                0x00007fff8a837437 JSC::GCThread::waitForNextPhase() + 119
    3   com.apple.JavaScriptCore                0x00007fff8a8372c8 JSC::GCThread::gcThreadMain() + 88
    4   com.apple.JavaScriptCore                0x00007fff8a82bc5f ***::wtfThreadEntryPoint(void*) + 15
    5   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    6   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    7   libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 8:: JavaScriptCore::Marking
    0   libsystem_kernel.dylib                  0x00007fff8c8c7716 __psynch_cvwait + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7fc3b _pthread_cond_wait + 727
    2   com.apple.JavaScriptCore                0x00007fff8a837437 JSC::GCThread::waitForNextPhase() + 119
    3   com.apple.JavaScriptCore                0x00007fff8a8372c8 JSC::GCThread::gcThreadMain() + 88
    4   com.apple.JavaScriptCore                0x00007fff8a82bc5f ***::wtfThreadEntryPoint(void*) + 15
    5   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    6   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    7   libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 9:: JavaScriptCore::Marking
    0   libsystem_kernel.dylib                  0x00007fff8c8c7716 __psynch_cvwait + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7fc3b _pthread_cond_wait + 727
    2   com.apple.JavaScriptCore                0x00007fff8a837437 JSC::GCThread::waitForNextPhase() + 119
    3   com.apple.JavaScriptCore                0x00007fff8a8372c8 JSC::GCThread::gcThreadMain() + 88
    4   com.apple.JavaScriptCore                0x00007fff8a82bc5f ***::wtfThreadEntryPoint(void*) + 15
    5   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    6   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    7   libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 10:: JavaScriptCore::Marking
    0   libsystem_kernel.dylib                  0x00007fff8c8c7716 __psynch_cvwait + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7fc3b _pthread_cond_wait + 727
    2   com.apple.JavaScriptCore                0x00007fff8a837437 JSC::GCThread::waitForNextPhase() + 119
    3   com.apple.JavaScriptCore                0x00007fff8a8372c8 JSC::GCThread::gcThreadMain() + 88
    4   com.apple.JavaScriptCore                0x00007fff8a82bc5f ***::wtfThreadEntryPoint(void*) + 15
    5   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    6   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    7   libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 11:: JavaScriptCore::Marking
    0   libsystem_kernel.dylib                  0x00007fff8c8c7716 __psynch_cvwait + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7fc3b _pthread_cond_wait + 727
    2   com.apple.JavaScriptCore                0x00007fff8a837437 JSC::GCThread::waitForNextPhase() + 119
    3   com.apple.JavaScriptCore                0x00007fff8a8372c8 JSC::GCThread::gcThreadMain() + 88
    4   com.apple.JavaScriptCore                0x00007fff8a82bc5f ***::wtfThreadEntryPoint(void*) + 15
    5   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    6   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    7   libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 12:
    0   libsystem_kernel.dylib                  0x00007fff8c8c7e6a __workq_kernreturn + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7ef08 _pthread_wqthread + 330
    2   libsystem_pthread.dylib                 0x00007fff95c81fb9 start_wqthread + 13
    Thread 13:
    0   libsystem_kernel.dylib                  0x00007fff8c8c7e6a __workq_kernreturn + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7ef08 _pthread_wqthread + 330
    2   libsystem_pthread.dylib                 0x00007fff95c81fb9 start_wqthread + 13
    Thread 14:: WebCore: Worker
    0   libsystem_kernel.dylib                  0x00007fff8c8c7716 __psynch_cvwait + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7fc3b _pthread_cond_wait + 727
    2   com.apple.JavaScriptCore                0x00007fff8a836ddd ***::ThreadCondition::timedWait(***::Mutex&, double) + 61
    3   com.apple.WebCore                       0x00007fff8fbbe2cb ***::PassOwnPtr<WebCore::WorkerRunLoop::Task> ***::MessageQueue<WebCore::WorkerRunLoop::Task>::waitForMessageFilteredWithTime out<WebCore::ModePredicate const>(***::MessageQueueWaitResult&, WebCore::ModePredicate const&, double) + 187
    4   com.apple.WebCore                       0x00007fff8fbbdcf6 WebCore::WorkerRunLoop::runInMode(WebCore::WorkerContext*, WebCore::ModePredicate const&, WebCore::WorkerRunLoop::WaitMode) + 102
    5   com.apple.WebCore                       0x00007fff8fbbdc50 WebCore::WorkerRunLoop::run(WebCore::WorkerContext*) + 80
    6   com.apple.WebCore                       0x00007fff8fbc0f50 WebCore::WorkerThread::workerThread() + 624
    7   com.apple.JavaScriptCore                0x00007fff8a82bc5f ***::wtfThreadEntryPoint(void*) + 15
    8   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    9   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    10  libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 15:: JavaScriptCore::BlockFree
    0   libsystem_kernel.dylib                  0x00007fff8c8c7716 __psynch_cvwait + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7fc3b _pthread_cond_wait + 727
    2   com.apple.JavaScriptCore                0x00007fff8a8369c5 JSC::BlockAllocator::blockFreeingThreadMain() + 261
    3   com.apple.JavaScriptCore                0x00007fff8a82bc5f ***::wtfThreadEntryPoint(void*) + 15
    4   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    5   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    6   libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 16:: JavaScriptCore::Marking
    0   libsystem_kernel.dylib                  0x00007fff8c8c7716 __psynch_cvwait + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7fc3b _pthread_cond_wait + 727
    2   com.apple.JavaScriptCore                0x00007fff8a837437 JSC::GCThread::waitForNextPhase() + 119
    3   com.apple.JavaScriptCore                0x00007fff8a8372c8 JSC::GCThread::gcThreadMain() + 88
    4   com.apple.JavaScriptCore                0x00007fff8a82bc5f ***::wtfThreadEntryPoint(void*) + 15
    5   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    6   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    7   libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 17:: JavaScriptCore::Marking
    0   libsystem_kernel.dylib                  0x00007fff8c8c7716 __psynch_cvwait + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7fc3b _pthread_cond_wait + 727
    2   com.apple.JavaScriptCore                0x00007fff8a837437 JSC::GCThread::waitForNextPhase() + 119
    3   com.apple.JavaScriptCore                0x00007fff8a8372c8 JSC::GCThread::gcThreadMain() + 88
    4   com.apple.JavaScriptCore                0x00007fff8a82bc5f ***::wtfThreadEntryPoint(void*) + 15
    5   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    6   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    7   libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 18:: JavaScriptCore::Marking
    0   libsystem_kernel.dylib                  0x00007fff8c8c7716 __psynch_cvwait + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7fc3b _pthread_cond_wait + 727
    2   com.apple.JavaScriptCore                0x00007fff8a837437 JSC::GCThread::waitForNextPhase() + 119
    3   com.apple.JavaScriptCore                0x00007fff8a8372c8 JSC::GCThread::gcThreadMain() + 88
    4   com.apple.JavaScriptCore                0x00007fff8a82bc5f ***::wtfThreadEntryPoint(void*) + 15
    5   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    6   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    7   libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 19:: JavaScriptCore::Marking
    0   libsystem_kernel.dylib                  0x00007fff8c8c7716 __psynch_cvwait + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7fc3b _pthread_cond_wait + 727
    2   com.apple.JavaScriptCore                0x00007fff8a837437 JSC::GCThread::waitForNextPhase() + 119
    3   com.apple.JavaScriptCore                0x00007fff8a8372c8 JSC::GCThread::gcThreadMain() + 88
    4   com.apple.JavaScriptCore                0x00007fff8a82bc5f ***::wtfThreadEntryPoint(void*) + 15
    5   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    6   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    7   libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 20:: JavaScriptCore::Marking
    0   libsystem_kernel.dylib                  0x00007fff8c8c7716 __psynch_cvwait + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7fc3b _pthread_cond_wait + 727
    2   com.apple.JavaScriptCore                0x00007fff8a837437 JSC::GCThread::waitForNextPhase() + 119
    3   com.apple.JavaScriptCore                0x00007fff8a8372c8 JSC::GCThread::gcThreadMain() + 88
    4   com.apple.JavaScriptCore                0x00007fff8a82bc5f ***::wtfThreadEntryPoint(void*) + 15
    5   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    6   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    7   libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 21:: JavaScriptCore::Marking
    0   libsystem_kernel.dylib                  0x00007fff8c8c7716 __psynch_cvwait + 10
    1   libsystem_pthread.dylib                 0x00007fff95c7fc3b _pthread_cond_wait + 727
    2   com.apple.JavaScriptCore                0x00007fff8a837437 JSC::GCThread::waitForNextPhase() + 119
    3   com.apple.JavaScriptCore                0x00007fff8a8372c8 JSC::GCThread::gcThreadMain() + 88
    4   com.apple.JavaScriptCore                0x00007fff8a82bc5f ***::wtfThreadEntryPoint(void*) + 15
    5   libsystem_pthread.dylib                 0x00007fff95c7d899 _pthread_body + 138
    6   libsystem_pthread.dylib                 0x00007fff95c7d72a _pthread_start + 137
    7   libsystem_pthread.dylib                 0x00007fff95c81fc9 thread_start + 13
    Thread 0 crashed with X86 Thread State (64-bit):
      rax: 0x00007fff5413ef78  rbx: 0x0000000000000000  rcx: 0x00007fe085a2dcb8  rdx: 0x00007fe085a2dcb8
      rdi: 0x0000000000000000  rsi: 0x00007fff5413ef90  rbp: 0x00007fff5413ef60  rsp: 0x00007fff5413ef50
       r8: 0x0000000000000000   r9: 0x0000000000000190  r10: 0xfffffffffffffe91  r11: 0x00007fff7be09db8
      r12: 0x000000011100b8c0  r13: 0x00007fff5413ef90  r14: 0x00007fff92408c1e  r15: 0x0000000000000000
      rip: 0x00007fff922c9212  rfl: 0x0000000000010246  cr2: 0x0000000000000008
    Logical CPU:     6
    Error Code:      0x00000004
    Trap Number:     14
    Binary Images:

    This procedure is a diagnostic test. It will make no changes to your system, and therefore will not, in itself, solve your problem.
    If you have more than one user account, you must be logged in as an administrator to carry out these instructions.
    Triple-click anywhere in the line below to select it:
    sudo opensnoop -e 2>&- | sed -En '/ m[dt]/d;s/(\/Users\/)[^/]+/\1-/p;/ReportC/q' | tail -50 | pbcopy
    Copy the selected text to the Clipboard by pressing the key combination command-C.
    Launch the built-in Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
    Paste into the Terminal window (command-V). You'll be prompted for your login password. Nothing will be displayed when you type it. If you don’t have a login password, you’ll need to set one before you can run the command. You may get a one-time warning not to screw up. Confirm. You don't need to post the warning.
    If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator. Log in as one and start over.
    Now take the action that causes the crash.
    The command may take a noticeable amount of time to run. Wait for a new line ending in a dollar sign ($) to appear.
    The output of the command will be automatically copied to the Clipboard. If the command produced no output, the Clipboard will be empty. Paste into a reply to this message.
    The Terminal window doesn't show the output. Please don't copy anything from there.
    If any personal information appears in the output, anonymize before posting, but don’t remove the context.
    You can then quit Terminal.
    Important: There is an obscure bug in some versions of OS X that may cause cursor movement to lag or stutter after running the above command. If you notice this behavior, simply restart the computer to clear it.

  • A problem with threads

    I am trying to implement some kind of a server listening for requests. The listener part of the app, is a daemon thread that listens for connections and instantiates a handling daemon thread once it gets some. However, my problem is that i must be able to kill the listening thread at the user's will (say via a sto button). I have done this via the Sun's proposed way, by testing a boolean flag in the loop, which is set to false when i wish to kill the thread. The problem with this thing is the following...
    Once the thread starts excecuting, it will test the flag, find it true and enter the loop. At some point it will LOCK on the server socket waiting for connection. Unless some client actually connects, it will keep on listening indefinatelly whithought ever bothering to check for the flag again (no matter how many times you set the damn thing to false).
    My question is this: Is there any real, non-theoretical, applied way to stop thread in java safely?
    Thank you in advance,
    Lefty

    This was one solution from the socket programming forum, have you tried this??
    public Thread MyThread extends Thread{
         boolean active = true;          
         public void run(){
              ss.setSoTimeout(90);               
              while (active){                   
                   try{                       
                        serverSocket = ss.accept();
                   catch (SocketTimeoutException ste){
                   // do nothing                   
         // interrupt thread           
         public void deactivate(){               
              active = false;
              // you gotta sleep for a time longer than the               
              // accept() timeout to make sure that timeout is finished.               
              try{
                   sleep(91);               
              }catch (InterruptedException ie){            
              interrupt();
    }

Maybe you are looking for