Search Results

Search found 8588 results on 344 pages for 'thread abort'.

Page 57/344 | < Previous Page | 53 54 55 56 57 58 59 60 61 62 63 64  | Next Page >

  • How to create a Request Specific Thread Safe Static int Counter?

    - by user960567
    In one of my server application I have a class that look like, class A { static int _value = 0; void DoSomething() { // a request start here _value = 0; _value++; // a request end here } // This method can be called many time during request void SomeAsyncMethods() { _value++; } } The problem is SomeAsyncMethods is async. Can be called many times. What I need when a request start set _value = 0 and then asynchrosnously increment this. After end of request I need the total. But the problem is that another request at the same time can access the class.

    Read the article

  • Plagued by multithreaded bugs

    - by koncurrency
    On my new team that I manage, the majority of our code is platform, TCP socket, and http networking code. All C++. Most of it originated from other developers that have left the team. The current developers on the team are very smart, but mostly junior in terms of experience. Our biggest problem: multi-threaded concurrency bugs. Most of our class libraries are written to be asynchronous by use of some thread pool classes. Methods on the class libraries often enqueue long running taks onto the thread pool from one thread and then the callback methods of that class get invoked on a different thread. As a result, we have a lot of edge case bugs involving incorrect threading assumptions. This results in subtle bugs that go beyond just having critical sections and locks to guard against concurrency issues. What makes these problems even harder is that the attempts to fix are often incorrect. Some mistakes I've observed the team attempting (or within the legacy code itself) includes something like the following: Common mistake #1 - Fixing concurrency issue by just put a lock around the shared data, but forgetting about what happens when methods don't get called in an expected order. Here's a very simple example: void Foo::OnHttpRequestComplete(statuscode status) { m_pBar->DoSomethingImportant(status); } void Foo::Shutdown() { m_pBar->Cleanup(); delete m_pBar; m_pBar=nullptr; } So now we have a bug in which Shutdown could get called while OnHttpNetworkRequestComplete is occuring on. A tester finds the bug, captures the crash dump, and assigns the bug to a developer. He in turn fixes the bug like this. void Foo::OnHttpRequestComplete(statuscode status) { AutoLock lock(m_cs); m_pBar->DoSomethingImportant(status); } void Foo::Shutdown() { AutoLock lock(m_cs); m_pBar->Cleanup(); delete m_pBar; m_pBar=nullptr; } The above fix looks good until you realize there's an even more subtle edge case. What happens if Shutdown gets called before OnHttpRequestComplete gets called back? The real world examples my team has are even more complex, and the edge cases are even harder to spot during the code review process. Common Mistake #2 - fixing deadlock issues by blindly exiting the lock, wait for the other thread to finish, then re-enter the lock - but without handling the case that the object just got updated by the other thread! Common Mistake #3 - Even though the objects are reference counted, the shutdown sequence "releases" it's pointer. But forgets to wait for the thread that is still running to release it's instance. As such, components are shutdown cleanly, then spurious or late callbacks are invoked on an object in an state not expecting any more calls. There are other edge cases, but the bottom line is this: Multithreaded programming is just plain hard, even for smart people. As I catch these mistakes, I spend time discussing the errors with each developer on developing a more appropriate fix. But I suspect they are often confused on how to solve each issue because of the enormous amount of legacy code that the "right" fix will involve touching. We're going to be shipping soon, and I'm sure the patches we're applying will hold for the upcoming release. Afterwards, we're going to have some time to improve the code base and refactor where needed. We won't have time to just re-write everything. And the majority of the code isn't all that bad. But I'm looking to refactor code such that threading issues can be avoided altogether. One approach I am considering is this. For each significant platform feature, have a dedicated single thread where all events and network callbacks get marshalled onto. Similar to COM apartment threading in Windows with use of a message loop. Long blocking operations could still get dispatched to a work pool thread, but the completion callback is invoked on on the component's thread. Components could possibly even share the same thread. Then all the class libraries running inside the thread can be written under the assumption of a single threaded world. Before I go down that path, I am also very interested if there are other standard techniques or design patterns for dealing with multithreaded issues. And I have to emphasize - something beyond a book that describes the basics of mutexes and semaphores. What do you think? I am also interested in any other approaches to take towards a refactoring process. Including any of the following: Literature or papers on design patterns around threads. Something beyond an introduction to mutexes and semaphores. We don't need massive parallelism either, just ways to design an object model so as to handle asynchronous events from other threads correctly. Ways to diagram the threading of various components, so that it will be easy to study and evolve solutions for. (That is, a UML equivalent for discussing threads across objects and classes) Educating your development team on the issues with multithreaded code. What would you do?

    Read the article

  • Problem with a blocking network task

    - by user326967
    Hello everyone. I'm new in Java so please forgive any obscene errors that I may make :) I'm developing a program in Java that among other things it should also handle clients that will connect to a server. The server has 3 threads running, and I have created them in the following way : DaemonForUI du; DaemonForPort da; DaemonForCheck dc; da = new DaemonForPort(3); dc = new DaemonForCheck(5); du = new DaemonForUI(7); Thread t_port = new Thread(da); Thread t_check = new Thread(dc); Thread t_ui = new Thread(du); t_port.setName("v1.9--PORTd"); t_check.setName("v1.9-CHECKd"); t_ui.setName("v1.9----UId"); t_port.start(); t_check.start(); t_ui.start(); Each thread handles a different aspect of the complete program. The thread t_ui is responsible to accept asynchronous incoming connections from clients, process the sent data and send other data back to the client. When I remove all the commands from the previous piece of code that has to with the t_ui thread, everything runs ok which in my case means that the other threads are printing their debug messages. If I set the t_ui thread to run too, then the whole program blocks at the "accept" of the t_ui thread. After reading at online manuals I saw that the accepted connections should be non-blocking, therefore use something like that : public ServerSocketChannel ssc = null; ssc = ServerSocketChannel.open(); ssc.socket().bind(new InetSocketAddress(port)); ssc.configureBlocking(false); SocketChannel sc = ssc.accept(); if (sc == null) { ; } else { System.out.println("The server and client are connected!"); System.out.println("Incoming connection from: " + sc.socket().getRemoteSocketAddress()); in = new DataInputStream(new BufferedInputStream(sc.socket().getInputStream())); out = new DataOutputStream(new BufferedOutputStream(sc.socket().getOutputStream())); //other magic things take place after that point... The thread for t_ui is created as follows : class DaemonForUI implements Runnable{ private int cnt; private int rr; public ListenerForUI serverListener; public DaemonForUI(int rr){ cnt = 0; this.rr = rr; serverListener = new ListenerForUI(); } public static String getCurrentTime() { final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss"; Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW); return (sdf.format(cal.getTime())); } public void run() { while(true) { System.out.println(Thread.currentThread().getName() + "\t (" + cnt + ")\t (every " + rr + " sec) @ " + getCurrentTime()); try{ Thread.sleep(rr * 1000); cnt++; } catch (InterruptedException e){ e.printStackTrace(); } } } } Obviously, I'm doing something wrong at the creation of the socket or at the use of the thread. Do you know what is causing the problem? Every help would be greatly appreciated.

    Read the article

  • Motion - can't get streaming working from a webcam

    - by Emmanuel Brunet
    I'm trying to record a video stream from my Tenvis IP camera with motion 3.2.12 on Debian 7.5. I used the standard debian package with sudo apt-get install motion Assume my DNS IP cam is webcam, user : admin, password : password /etc/motion/motion.conf Bellow are my configuration file settings : netcam_url http://webcam/videostream.cgi netcam_userpass admin:password target_dir /media/videos/log/motion # The mini-http server listens to this port for requests (default: 0 = disabled) webcam_port 1234 ffmpeg_cap_new on ffmpeg_video_codec mpeg4 output_motion off snapshot_interval 0 # Quality of the jpeg (in percent) images produced (default: 50) webcam_quality 50 # Output frames at 1 fps when no motion is detected and increase to the # rate given by webcam_maxrate when motion is detected (default: off) webcam_motion on # Maximum framerate for webcam streams (default: 1) webcam_maxrate 15 # Restrict webcam connections to localhost only (default: on) webcam_localhost on # Limits the number of images per connection (default: 0 = unlimited) # Number can be defined by multiplying actual webcam rate by desired number of seconds # Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate webcam_limit 0 control_port 8080 control_authentication admin:password Issue #1 when I try display http:/localhost:1234 the browser looks frozen, no HTTP 404 received but it stills waiting for data it seems .. Issue #2 in the output directory motion writes a lot of jpeg snapshots althought I just want to have several video sequenced files. Log I run motion in interactive mode in a terminal, here is the ouput root@mercure:/etc/motion# motion -c motion-1.0.conf [0] Processing thread 0 - config file motion-1.0.conf [0] Motion 3.2.12 Started [0] ffmpeg LIBAVCODEC_BUILD 3482368 LIBAVFORMAT_BUILD 3478785 [0] Thread 1 is from motion-1.0.conf [0] motion-httpd/3.2.12 running, accepting connections [0] motion-httpd: waiting for data on port TCP 8080 [1] Thread 1 started [1] Resizing pre_capture buffer to 1 items [1] Started stream webcam server in port 1234 [1] avcodec_open - could not open codec: Operation now in progress [1] ffopen_open error creating (new) file [~/tmp/motion/01-20140603165303.avi]: Operation now in progress [1] File of type 1 saved to: ~/tmp/motion/01-20140603165303-01.jpg [1] Thread exiting [1] Calling vid_close() from motion_cleanup [1] vid_close: calling netcam_cleanup [1] netcam camera handler: finish set, exiting [0] Motion thread 1 restart [1] Thread 1 started [1] Resizing pre_capture buffer to 1 items [1] Started stream webcam server in port 1234 [1] avcodec_open - could not open codec: Resource temporarily unavailable [1] ffopen_open error creating (new) file [~/tmp/motion/01-20140603165329.avi]: Resource temporarily unavailable [1] File of type 1 saved to: ~/tmp/motion/01-20140603165329-00.jpg [1] Thread exiting [1] Calling vid_close() from motion_cleanup [1] vid_close: calling netcam_cleanup [1] netcam camera handler: finish set, exiting [0] Motion thread 1 restart [1] Thread 1 started [1] Resizing pre_capture buffer to 1 items [1] Started stream webcam server in port 1234 [1] avcodec_open - could not open codec: Connection reset by peer [1] ffopen_open error creating (new) file [~/tmp/motion/01-20140603165355.avi]: Connection reset by peer [1] File of type 1 saved to: ~/tmp/motion/01-20140603165355-06.jpg [1] Thread exiting [1] Calling vid_close() from motion_cleanup [1] vid_close: calling netcam_cleanup [0] httpd - Finishing [0] httpd Closing [0] httpd thread exit [1] netcam camera handler: finish set, exiting [0] Motion thread 1 restart [1] Thread 1 started [1] Resizing pre_capture buffer to 1 items [1] Started stream webcam server in port 1234 It doesn't find the codec ... avcodec_open - could not open codec: Operation now in progress I've changed fmpeg_video_codec from mpeg4 to swf the result is the same. When using flv format motion writes a lot of .jpg image but I can't see anything at http://localhost:1234 [1] File of type 1 saved to: ~/tmp/motion/01-20140603171035-00.jpg [1] File of type 1 saved to: ~/tmp/motion/01-20140603171035-01.jpg [1] File of type 1 saved to: ~/tmp/motion/01-20140603171035-02.jpg [1] File of type 1 saved to: ~/tmp/motion/01-20140603171035-03.jpg [1] File of type 1 saved to: ~/tmp/motion/01-20140603171035-04.jpg [1] File of type 1 saved to: ~/tmp/motion/01-20140603171035-05.jpg [1] File of type 1 saved to: ~/tmp/motion/01-20140603171035-06.jpg [1] File of type 1 saved to: ~/tmp/motion/01-20140603171036-00.jpg [1] File of type 1 saved to: ~/tmp/motion/01-20140603171036-01.jpg [1] File of type 1 saved to: ~/tmp/motion/01-20140603171036-02.jpg Any idea just to get the video stream recoded on my local disk ?

    Read the article

  • Innodb Queries Slow

    - by user105196
    I have redHat 5.3 (Tikanga) with Mysql 5.0.86 configued with RIAD 10 HW, I run an application inquiries from Mysql/InnoDB and MyIsam tables, the queries are super fast,but some quires on Innodb tables sometime slow down and took more than 1-3 seconds to run and these queries are simple and optimized, this problem occurred just on innodb tables in different time with random queries. Why is this happening only to Innodb tables? the below is the Innodb status and some Mysql variables: show innodb status\G ************* 1. row ************* Status: 120325 10:54:08 INNODB MONITOR OUTPUT Per second averages calculated from the last 19 seconds SEMAPHORES OS WAIT ARRAY INFO: reservation count 22943, signal count 22947 Mutex spin waits 0, rounds 561745, OS waits 7664 RW-shared spins 24427, OS waits 12201; RW-excl spins 1461, OS waits 1277 TRANSACTIONS Trx id counter 0 119069326 Purge done for trx's n:o < 0 119069326 undo n:o < 0 0 History list length 41 Total number of lock structs in row lock hash table 0 LIST OF TRANSACTIONS FOR EACH SESSION: ---TRANSACTION 0 0, not started, process no 29093, OS thread id 1166043456 MySQL thread id 703985, query id 5807220 localhost root show innodb status FILE I/O I/O thread 0 state: waiting for i/o request (insert buffer thread) I/O thread 1 state: waiting for i/o request (log thread) I/O thread 2 state: waiting for i/o request (read thread) I/O thread 3 state: waiting for i/o request (write thread) Pending normal aio reads: 0, aio writes: 0, ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0 Pending flushes (fsync) log: 0; buffer pool: 0 132777 OS file reads, 689086 OS file writes, 252010 OS fsyncs 0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s INSERT BUFFER AND ADAPTIVE HASH INDEX Ibuf: size 1, free list len 366, seg size 368, 62237 inserts, 62237 merged recs, 52881 merges Hash table size 8850487, used cells 3698960, node heap has 7061 buffer(s) 0.00 hash searches/s, 0.00 non-hash searches/s LOG Log sequence number 15 3415398745 Log flushed up to 15 3415398745 Last checkpoint at 15 3415398745 0 pending log writes, 0 pending chkp writes 218214 log i/o's done, 0.00 log i/o's/second BUFFER POOL AND MEMORY Total memory allocated 4798817080; in additional pool allocated 12342784 Buffer pool size 262144 Free buffers 101603 Database pages 153480 Modified db pages 0 Pending reads 0 Pending writes: LRU 0, flush list 0, single page 0 Pages read 151954, created 1526, written 494505 0.00 reads/s, 0.00 creates/s, 0.00 writes/s No buffer pool page gets since the last printout ROW OPERATIONS 0 queries inside InnoDB, 0 queries in queue 1 read views open inside InnoDB Main thread process no. 29093, id 1162049856, state: waiting for server activity Number of rows inserted 77675, updated 85439, deleted 0, read 14377072495 0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s END OF INNODB MONITOR OUTPUT 1 row in set, 1 warning (0.02 sec) read_buffer_size = 128M sort_buffer_size = 256M tmp_table_size = 1024M innodb_additional_mem_pool_size = 20M innodb_log_file_size=10M innodb_lock_wait_timeout=100 innodb_buffer_pool_size=4G join_buffer_size = 128M key_buffer_size = 1G can any one help me ?

    Read the article

  • Weird nfs performance: 1 thread better than 8, 8 better than 2!

    - by Joe
    I'm trying to determine the cause of poor nfs performance between two Xen Virtual Machines (client & server) running on the same host. Specifically, the speed at which I can sequentially read a 1GB file on the client is much lower than what would be expected based on the measured network connection speed between the two VMs and the measured speed of reading the file directly on the server. The VMs are running Ubuntu 9.04 and the server is using the nfs-kernel-server package. According to various NFS tuning resources, changing the number of nfsd threads (in my case kernel threads) can affect performance. Usually this advice is framed in terms of increasing the number from the default of 8 on heavily-used servers. What I find in my current configuration: RPCNFSDCOUNT=8: (default): 13.5-30 seconds to cat a 1GB file on the client so 35-80MB/sec RPCNFSDCOUNT=16: 18s to cat the file 60MB/s RPCNFSDCOUNT=1: 8-9 seconds to cat the file (!!?!) 125MB/s RPCNFSDCOUNT=2: 87s to cat the file 12MB/s I should mention that the file I'm exporting is on a RevoDrive SSD mounted on the server using Xen's PCI-passthrough; on the server I can cat the file in under seconds ( 250MB/s). I am dropping caches on the client before each test. I don't really want to leave the server configured with just one thread as I'm guessing that won't work so well when there are multiple clients, but I might be misunderstanding how that works. I have repeated the tests a few times (changing the server config in between) and the results are fairly consistent. So my question is: why is the best performance with 1 thread? A few other things I have tried changing, to little or no effect: increasing the values of /proc/sys/net/ipv4/ipfrag_low_thresh and /proc/sys/net/ipv4/ipfrag_high_thresh to 512K, 1M from the default 192K,256K increasing the value of /proc/sys/net/core/rmem_default and /proc/sys/net/core/rmem_max to 1M from the default of 128K mounting with client options rsize=32768, wsize=32768 From the output of sar -d I understand that the actual read sizes going to the underlying device are rather small (<100 bytes) but this doesn't cause a problem when reading the file locally on the client. The RevoDrive actually exposes two "SATA" devices /dev/sda and /dev/sdb, then dmraid picks up a fakeRAID-0 striped across them which I have mounted to /mnt/ssd and then bind-mounted to /export/ssd. I've done local tests on my file using both locations and see the good performance mentioned above. If answers/comments ask for more details I will add them.

    Read the article

  • How do you create a non-Thread-based Guice custom Scope?

    - by Russ
    It seems that all Guice's out-of-the-box Scope implementations are inherently Thread-based (or ignore Threads entirely): Scopes.SINGLETON and Scopes.NO_SCOPE ignore Threads and are the edge cases: global scope and no scope. ServletScopes.REQUEST and ServletScopes.SESSION ultimately depend on retrieving scoped objects from a ThreadLocal<Context>. The retrieved Context holds a reference to the HttpServletRequest that holds a reference to the scoped objects stored as named attributes (where name is derived from com.google.inject.Key). Class SimpleScope from the custom scope Guice wiki also provides a per-Thread implementation using a ThreadLocal<Map<Key<?>, Object>> member variable. With that preamble, my question is this: how does one go about creating a non-Thread-based Scope? It seems that something that I can use to look up a Map<Key<?>, Object> is missing, as the only things passed in to Scope.scope() are a Key<T> and a Provider<T>. Thanks in advance for your time.

    Read the article

  • How to make a thread that runs at x:00 x:15 x:30 and x:45 do something different at 2:00.

    - by rmarimon
    I have a timer thread that needs to run at a particular moments of the day to do an incremental replication with a database. Right now it runs at the hour, 15 minutes past the hour, 30 minutes past the hour and 45 minutes past the hour. This is the code I have which is working ok: public class TimerRunner implements Runnable { private static final Semaphore lock = new Semaphore(1); private static final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); public static void initialize() { long delay = getDelay(); executor.schedule(new TimerRunner(), delay, TimeUnit.SECONDS); } public static void destroy() { executor.shutdownNow(); } private static long getDelay() { Calendar now = Calendar.getInstance(); long p = 15 * 60; // run at 00, 15, 30 and 45 minutes past the hour long second = now.get(Calendar.MINUTE) * 60 + now.get(Calendar.SECOND); return p - (second % p); } public static void replicate() { if (lock.tryAcquire()) { try { Thread t = new Thread(new Runnable() { public void run() { try { // here is where the magic happens } finally { lock.release(); } } }); t.start(); } catch (Exception e) { lock.release(); } } else { throw new IllegalStateException("already running a replicator"); } } public void run() { try { TimerRunner.replicate(); } finally { long delay = getDelay(); executor.schedule(new TimerRunner(), delay, TimeUnit.SECONDS); } } } This process is started by calling TimerRunner.initialize() when a server starts and calling TimerRunner.destroy(). I have created a full replication process (as opposed to incremental) that I would like to run at a certain moment of the day, say 2:00am. How would change the above code to do this? I think that it should be very simple something like if it is now around 2:00am and it's been a long time since I did the full replication then do it now, but I can't get the if right. Beware that sometimes the replicate process takes way longer to complete. Sometimes beyond the 15 minutes, posing a problem in running at around 2:00am.

    Read the article

  • Why thread in background is not waiting for task to complete?

    - by Haris Hasan
    I am playing with async await feature of C#. Things work as expected when I use it with UI thread. But when I use it in a non-UI thread it doesn't work as expected. Consider the code below private void Click_Button(object sender, RoutedEventArgs e) { var bg = new BackgroundWorker(); bg.DoWork += BgDoWork; bg.RunWorkerCompleted += BgOnRunWorkerCompleted; bg.RunWorkerAsync(); } private void BgOnRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs runWorkerCompletedEventArgs) { } private async void BgDoWork(object sender, DoWorkEventArgs doWorkEventArgs) { await Method(); } private static async Task Method() { for (int i = int.MinValue; i < int.MaxValue; i++) { var http = new HttpClient(); var tsk = await http.GetAsync("http://www.ebay.com"); } } When I execute this code, background thread don't wait for long running task in Method to complete. Instead it instantly executes the BgOnRunWorkerCompleted after calling Method. Why is that so? What am I missing here? P.S: I am not interested in alternate ways or correct ways of doing this. I want to know what is actually happening behind the scene in this case? Why is it not waiting?

    Read the article

  • difference between http.context.user and thread.currentprincipal and when to use them?

    - by yamspog
    I have just recently run into an issue running an asp.net web app under visual studio 2008. I get the error 'type is not resolved for member...customUserPrincipal'. Tracking down various discussion groups it seems that there is an issue with Visual Studio's web server when you assign a custom principal against the Thread.CurrentPrincipal. In my code, I now use... HttpContext.Current.User = myCustomPrincipal //Thread.CurrentPrincipal = myCustomPrincipal I'm glad that I got the error out of the way, but it begs the question "What is the difference between these two methods of setting a principal?". There are other stackoverflow questions related to the differences but they don't get into the details of the two approaches. I did find one tantalizing post that had the following grandiose comment but no explanation to back up his assertions... Use HttpConext.Current.User for all web (ASPX/ASMX) applications. Use Thread.CurrentPrincipal for all other applications like winForms, console and windows service applications. Can any of you security/dot.net gurus shed some light on this subject?

    Read the article

  • Concurrent Programming:Should I write a sequential program first, then add thread safety?

    - by evthim
    I'm working on a project where we have to create a number of threads(actual number will be inputted in by testers (TA's)). I'm having trouble not only with the programming but also with the design, I can't wrap my head around all of the threads that will be invoked and where I might cause errors. The project is due soon so I don't want to waste time on this if it'll actually set me back, but I was wondering if I should write the program like only one thread will be running and everything should be sequential and then later go back and try to add the thread safety parts of the code? Would that take twice the original amount of time? Project Description: Note:I'm going to be as vague as possible so I don't violate any honor codes, sorry :( your program should accept n number of objectA threads, m number of objectB threads, and r number of objectC objectB threads interact with code in objectA. objectA threads interact with code in objectB and objectC objectB and objectC don't directly interact, but do so indirectly through objectA -ex: objectB needs something from objectA. objectA gets the result for that something by calling objectC my confusion stems mostly from the fact that all of this interactions will be done by m+n threads and there are various restrictions throughout the descriptions, like objectB can request something from objectA, and objectA has to wait for objectC to finish that something before returning it to objectB. Also each objectA thread can only work on one instruction from objectB at a time, etc. etc. I just want to know if I write the code so that there is only 1 objectA, 1 objectB and 1 object C, can I go back and easily modify it so that those 1's can be changed to m, n and r? Sorry again, if my description is a little bit confusing.

    Read the article

  • creating a QT gui using a thread in c++?

    - by rashid
    I am trying to create this QT gui using a thread but no luck. Below is my code. Problem is gui never shows up. But if i put QApplication app(m.s_argc,m.s_argv); //object instantiation guiClass *gui = new guiClass(); //show gui gui-show(); app.exec(); in main() then it works. /*INCLUDES HERE... .... */ using namespace std; struct mainStruct { int s_argc; char ** s_argv; }; typedef struct mainStruct mas; void *guifunc(void * arg); int main(int argc, char * argv[]) { mas m; m.s_argc = argc; m.s_argv = argv; pthread_t threadGUI; //start a new thread for gui int result = pthread_create(&threadGUI, NULL, guifunc, (void *) &m); if (result) { printf("Error creating gui thread"); exit(0); } return 0; } void *guifunc(void * arg) { mas m = *(mas *)arg; QApplication app(m.s_argc,m.s_argv); //object instantiation guiClass *gui = new guiClass(); //show gui gui-show(); app.exec(); }

    Read the article

  • How do I stop Ant from hanging after executing a java program that attempted to interrupt a thread (and failed) and continued?

    - by Zugwalt
    I have Ant build and execute a java program. This program tries to do something that sometimes hangs, so we execute it in a thread. actionThread.start(); try { actionThread.join(10000); } catch (InterruptedException e) { System.out.println("InterruptedException: "+e.getMessage()); } if (actionThread.isAlive()) { actionThread.interrupt(); System.out.println("Thread timed out and never died"); } The ant call looks like this: <java fork="true" failonerror="yes" classname="myPackage.myPathName" classpath="build"> <arg line=""/> <classpath> <pathelement location="bin" /> <fileset dir="lib"> <include name="**/*.jar"/> </fileset> </classpath> </java> And when this runs I see the "Thread timed out and never died" statement, and I also see the main program finish execution, but then Ant just hangs. Presumably it is waiting for the child threads to finish, but they never will. How can I have Ant be done once it is done executing main() and just kill or ignore dead threads?

    Read the article

  • Why does the BackgroundWorker in WPF need Thread.Sleep to update UI controls?

    - by user364060
    namespace WpfApplication1 { /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : Window { BackgroundWorker bgWorker; Action<int> myProgressReporter; public Window1() { InitializeComponent(); bgWorker = new BackgroundWorker(); bgWorker.DoWork += bgWorker_Task; bgWorker.RunWorkerCompleted += myWorker_RunWorkerCompleted; // hook event to method bgWorker.ProgressChanged += bgWorker_ReportProgress; // hook the delegate to the method myProgressReporter = updateProgress; bgWorker.WorkerReportsProgress = true; } private void myWorker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) { object result; result = e.Result; MessageBox.Show(result.ToString()); progressBar1.Value = 0; button1.IsEnabled = true; } private void bgWorker_ReportProgress(object sender, ProgressChangedEventArgs e) { System.Windows.Threading.Dispatcher disp = button1.Dispatcher; disp.BeginInvoke(myProgressReporter,e.ProgressPercentage); //Dispatcher.BeginInvoke(myProgressReporter, DispatcherPriority.Normal, e.ProgressPercentage); } private void updateProgress(int progressPercentage) { progressBar1.Value = progressPercentage; } private void bgWorker_Task(Object sender, DoWorkEventArgs e) { int total = 1000; for (int i = 1; i <= total; i++) { if (bgWorker.WorkerReportsProgress) { int p = (int)(((float)i / (float)total) * 100); bgWorker.ReportProgress(p); } Thread.Sleep(1); // Without Thread.Sleep(x) the main thread freezes or gives stackoverflow exception, } e.Result = "Completed"; } private void button1_Click(object sender, RoutedEventArgs e) { if(!bgWorker.IsBusy) bgWorker.RunWorkerAsync("This is a background process"); button1.IsEnabled = false; } } }

    Read the article

  • Could it be that "chkrootkit" just doesn't like .hmac, .packlist, and .relocation-tag files?

    - by Danijel
    I just cleaned up my hacked CentOS server (due to not updating since versino 5.3). But still, "chkrootkit" says this: Possible t0rn v8 \(or variation\) rootkit installed /usr/lib/.libfipscheck.so.1.1.0.hmac /usr/lib/.libgcrypt.so.11.hmac /usr/lib/.libfipscheck.so.1.hmac /lib/.libcrypto.so.0.9.8e.hmac /lib/.libssl.so.0.9.8e.hmac /lib/.libssl.so.6.hmac /lib/.libcrypto.so.6.hmac /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/Text/Iconv/.packlist /usr/lib/perl5/5.8.8/i386-linux-thread-multi/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/HTML-Tree/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/Font/AFM/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/MLDBM/Sync/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/MLDBM/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/FreezeThaw/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/Apache/ASP/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/HTML-Format/.packlist /usr/lib/gtk-2.0/immodules/.relocation-tag /usr/lib/python2.4/plat-linux2/.relocation-tag /usr/lib/python2.4/distutils/.relocation-tag /usr/lib/python2.4/config/.relocation-tag Could it be that "chkrootkit" just doesn't like .hmac, .packlist, and .relocation-tag files? Are these realy still infected?

    Read the article

  • PPPD Is Locking the Modem and Not Releasing It

    - by Skid
    Got an issue with PPPD on one of our system, we have a PC that is used to talk to remote sites via a dial up connection, the modem can both connect out to the sites and the sites also dial back in. Currently I'm having an issue where some times a site ether dials in or we dial out, and it connects, but then blocks the modem and throws and error to kern.log. Aug 26 14:23:57 TM-SCADA kernel: [191233.503745] INFO: task pppd:8142 blocked for more than 120 seconds. Aug 26 14:23:57 TM-SCADA kernel: [191233.503750] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. Aug 26 14:23:57 TM-SCADA kernel: [191233.503753] pppd D ffffffff8180cb40 0 8142 1 0x00000000 Aug 26 14:23:57 TM-SCADA kernel: [191233.503759] ffff8800ac1f5dc8 0000000000000086 ffff8800ac1f5fd8 00000000000137c0 Aug 26 14:23:57 TM-SCADA kernel: [191233.503765] ffff8800ac1f4010 00000000000137c0 00000000000137c0 00000000000137c0 Aug 26 14:23:57 TM-SCADA kernel: [191233.503770] ffff8800ac1f5fd8 00000000000137c0 ffffffff81c13020 ffff880135df5b80 Aug 26 14:23:57 TM-SCADA kernel: [191233.503775] Call Trace: Aug 26 14:23:57 TM-SCADA kernel: [191233.503784] [<ffffffff8166ba29>] schedule+0x29/0x70 Aug 26 14:23:57 TM-SCADA kernel: [191233.503790] [<ffffffff813db005>] tty_ldisc_ref_wait+0x65/0xb0 Aug 26 14:23:57 TM-SCADA kernel: [191233.503796] [<ffffffff813f3061>] ? uart_ioctl+0xd1/0x1c0 Aug 26 14:23:57 TM-SCADA kernel: [191233.503801] [<ffffffff81076960>] ? wake_up_bit+0x40/0x40 Aug 26 14:23:57 TM-SCADA kernel: [191233.503806] [<ffffffff813d3fa0>] tty_ioctl+0x2c0/0x9a0 Aug 26 14:23:57 TM-SCADA kernel: [191233.503810] [<ffffffff811d0549>] ? fcntl_setlk+0x69/0x200 Aug 26 14:23:57 TM-SCADA kernel: [191233.503815] [<ffffffff81195f79>] do_vfs_ioctl+0x99/0x330 Aug 26 14:23:57 TM-SCADA kernel: [191233.503820] [<ffffffff81195212>] ? do_fcntl+0x232/0x410 Aug 26 14:23:57 TM-SCADA kernel: [191233.503823] [<ffffffff811962b1>] sys_ioctl+0xa1/0xb0 Aug 26 14:23:57 TM-SCADA kernel: [191233.503829] [<ffffffff81674e69>] system_call_fastpath+0x16/0x1b The syslog trace stops at "Serial connection established". Aug 28 06:00:03 TM-SCADA pppd[10358]: pppd 2.4.5 started by root, uid 0 Aug 28 06:00:04 TM-SCADA chat[10360]: abort on (NO CARRIER) Aug 28 06:00:04 TM-SCADA chat[10360]: abort on (NO DIALTONE) Aug 28 06:00:04 TM-SCADA chat[10360]: abort on (ERROR) Aug 28 06:00:04 TM-SCADA chat[10360]: abort on (NO ANSWER) Aug 28 06:00:04 TM-SCADA chat[10360]: abort on (BUSY) Aug 28 06:00:04 TM-SCADA chat[10360]: abort on (Username/Password Incorrect) Aug 28 06:00:04 TM-SCADA chat[10360]: send (atz^M) Aug 28 06:00:04 TM-SCADA chat[10360]: expect (OK) Aug 28 06:00:04 TM-SCADA chat[10360]: atz^M^M Aug 28 06:00:04 TM-SCADA chat[10360]: OK Aug 28 06:00:04 TM-SCADA chat[10360]: -- got it Aug 28 06:00:04 TM-SCADA chat[10360]: send (atx0^M) Aug 28 06:00:04 TM-SCADA chat[10360]: expect (OK) Aug 28 06:00:04 TM-SCADA chat[10360]: ^M Aug 28 06:00:04 TM-SCADA chat[10360]: atx0^M^M Aug 28 06:00:04 TM-SCADA chat[10360]: OK Aug 28 06:00:04 TM-SCADA chat[10360]: -- got it Aug 28 06:00:04 TM-SCADA chat[10360]: send (atdt0123456789^M) Aug 28 06:00:04 TM-SCADA chat[10360]: expect (CONNECT/ARQ) Aug 28 06:00:04 TM-SCADA chat[10360]: ^M Aug 28 06:00:30 TM-SCADA chat[10360]: atdt0123456789^M^M Aug 28 06:00:30 TM-SCADA chat[10360]: CONNECT/ARQ Aug 28 06:00:30 TM-SCADA chat[10360]: -- got it Aug 28 06:00:30 TM-SCADA pppd[10358]: Serial connection established. I've only found two ways to release the modem in this condition, the first is to turn the modem off and on again, the second is to delete the serial lock file, and then SIGKILL pppd. Now I could write into our software to do the latter if the modem is locked, but I would rather stop it from locking in the first place if at all possible. The reason I put this issue in the askubuntu is because we used to use OpenSuse and never had an issue with it, admittedly that was version 11.2 or earlier so its still and old kernel, but I figured I would ask here first anyway. Any suggestions of places to look would be appreciated.

    Read the article

  • Can't connect to VPN on Ubuntu 12.04

    - by 12rad
    I'm having a lot of trouble connecting to VPN. This used to work on my machine, but i recently did an update and it's stopped working. I'm not sure what the problem is. My question is how do i debug this? I'm not able to narrow it down to a specific problem. This is what i get when i tail the syslogs. Would appreciate any help! Nov 6 23:42:52 meera NetworkManager[1137]: <info> Starting VPN service 'pptp'... Nov 6 23:42:52 meera NetworkManager[1137]: <info> VPN service 'pptp' started (org.freedesktop.NetworkManager.pptp), PID 6132 Nov 6 23:42:52 meera NetworkManager[1137]: <info> VPN service 'pptp' appeared; activating connections Nov 6 23:42:52 meera NetworkManager[1137]: <info> VPN plugin state changed: starting (3) Nov 6 23:42:52 meera NetworkManager[1137]: <info> VPN connection 'NAME VPN' (Connect) reply received. Nov 6 23:42:52 meera pppd[6136]: Plugin /usr/lib/pppd/2.4.5/nm-pptp-pppd-plugin.so loaded. Nov 6 23:42:52 meera pppd[6136]: pppd 2.4.5 started by root, uid 0 Nov 6 23:42:52 meera chat[6139]: timeout set to 15 seconds Nov 6 23:42:52 meera chat[6139]: abort on (NO CARRIER) Nov 6 23:42:52 meera chat[6139]: abort on (NO DIALTONE) Nov 6 23:42:52 meera chat[6139]: abort on (ERROR) Nov 6 23:42:52 meera chat[6139]: abort on (NO ANSWER) Nov 6 23:42:52 meera chat[6139]: abort on (BUSY) Nov 6 23:42:52 meera chat[6139]: abort on (Username/Password Incorrect) Nov 6 23:42:52 meera chat[6139]: send (AT^M) Nov 6 23:42:52 meera pptp[6138]: nm-pptp-service-6132 log[main:pptp.c:314]: The synchronous pptp option is NOT activated Nov 6 23:42:52 meera chat[6139]: expect (OK) Nov 6 23:42:52 meera pptp[6143]: nm-pptp-service-6132 log[ctrlp_rep:pptp_ctrl.c:251]: Sent control packet type is 1 'Start-Control-Connection-Request' Nov 6 23:42:53 meera pptp[6143]: nm-pptp-service-6132 log[ctrlp_disp:pptp_ctrl.c:739]: Received Start Control Connection Reply Nov 6 23:42:53 meera pptp[6143]: nm-pptp-service-6132 log[ctrlp_disp:pptp_ctrl.c:773]: Client connection established. Nov 6 23:42:53 meera pptp[6143]: nm-pptp-service-6132 log[ctrlp_rep:pptp_ctrl.c:251]: Sent control packet type is 7 'Outgoing-Call-Request' Nov 6 23:42:54 meera pptp[6143]: nm-pptp-service-6132 log[ctrlp_disp:pptp_ctrl.c:858]: Received Outgoing Call Reply. Nov 6 23:42:54 meera pptp[6143]: nm-pptp-service-6132 log[ctrlp_disp:pptp_ctrl.c:897]: Outgoing call established (call ID 0, peer's call ID 13077). Nov 6 23:42:54 meera pptp[6138]: nm-pptp-service-6132 warn[decaps_hdlc:pptp_gre.c:231]: The ppp mode is synchronous, yet no pptp --sync option is specified! Nov 6 23:43:07 meera chat[6139]: alarm Nov 6 23:43:07 meera chat[6139]: Failed Nov 6 23:43:07 meera pppd[6136]: Script chat -v -f /etc/ppp/chat-ztisp finished (pid 6139), status = 0x3 Nov 6 23:43:07 meera pppd[6136]: Connect script failed Nov 6 23:43:07 meera pppd[6136]: Waiting for 1 child processes... Nov 6 23:43:07 meera pppd[6136]: script /usr/sbin/pptp 204.197.218.90 --nolaunchpppd --loglevel 0 --logstring nm-pptp-service-6132, pid 6138 Nov 6 23:43:07 meera pptp[6138]: nm-pptp-service-6132 warn[decaps_hdlc:pptp_gre.c:204]: short read (-1): Input/output error Nov 6 23:43:07 meera pptp[6138]: nm-pptp-service-6132 warn[decaps_hdlc:pptp_gre.c:216]: pppd may have shutdown, see pppd log Nov 6 23:43:07 meera pptp[6143]: nm-pptp-service-6132 log[callmgr_main:pptp_callmgr.c:234]: Closing connection (unhandled) Nov 6 23:43:07 meera pppd[6136]: Script /usr/sbin/pptp 204.197.218.90 --nolaunchpppd --loglevel 0 --logstring nm-pptp-service-6132 finished (pid 6138), status = 0x0 Nov 6 23:43:07 meera pptp[6143]: nm-pptp-service-6132 log[ctrlp_rep:pptp_ctrl.c:251]: Sent control packet type is 12 'Call-Clear-Request' Nov 6 23:43:07 meera pptp[6143]: nm-pptp-service-6132 log[call_callback:pptp_callmgr.c:79]: Closing connection (call state) Nov 6 23:43:07 meera pppd[6136]: Exit. Nov 6 23:43:07 meera NetworkManager[1137]: <warn> VPN plugin failed: 1 Nov 6 23:43:07 meera NetworkManager[1137]: <info> VPN plugin state changed: stopped (6) Nov 6 23:43:07 meera NetworkManager[1137]: <info> VPN plugin state change reason: 0 Nov 6 23:43:07 meera NetworkManager[1137]: <warn> error disconnecting VPN: Could not process the request because no VPN connection was active.

    Read the article

  • Creating a voxel world with 3D arrays using threads

    - by Sean M.
    I am making a voxel game (a bit like Minecraft) in C++(11), and I've come across an issue with creating a world efficiently. In my program, I have a World class, which holds a 3D array of Region class pointers. When I initialize the world, I give it a width, height, and depth so it knows how large of a world to create. Each Region is split up into a 32x32x32 area of blocks, so as you may guess, it takes a while to initialize the world once the world gets to be above 8x4x8 Regions. In order to alleviate this issue, I thought that using threads to generate different levels of the world concurrently would make it go faster. Having not used threads much before this, and being still relatively new to C++, I'm not entirely sure how to go about implementing one thread per level (level being a xz plane with a height of 1), when there is a variable number of levels. I tried this: for(int i = 0; i < height; i++) { std::thread th(std::bind(&World::load, this, width, height, depth)); th.join(); } Where load() just loads all Regions at height "height". But that executes the threads one at a time (which makes sense, looking back), and that of course takes as long as generating all Regions in one loop. I then tried: std::thread t1(std::bind(&World::load, this, w, h1, h2 - 1, d)); std::thread t2(std::bind(&World::load, this, w, h2, h3 - 1, d)); std::thread t3(std::bind(&World::load, this, w, h3, h4 - 1, d)); std::thread t4(std::bind(&World::load, this, w, h4, h - 1, d)); t1.join(); t2.join(); t3.join(); t4.join(); This works in that the world loads about 3-3.5 times faster, but this forces the height to be a multiple of 4, and it also gives the same exact VAO object to every single Region, which need individual VAOs in order to render properly. The VAO of each Region is set in the constructor, so I'm assuming that somehow the VAO number is not thread safe or something (again, unfamiliar with threads). So basically, my question is two one-part: How to I implement a variable number of threads that all execute at the same time, and force the main thread to wait for them using join() without stopping the other threads? How do I make the VAO objects thread safe, so when a bunch of Regions are being created at the same time across multiple threads, they don't all get the exact same VAO? Turns out it has to do with GL contexts not working across multiple threads. I moved the VAO/VBO creation back to the main thread. Fixed! Here is the code for block.h/.cpp, region.h/.cpp, and CVBObject.h/.cpp which controls VBOs and VAOs, in case you need it. If you need to see anything else just ask. EDIT: Also, I'd prefer not to have answers that are like "you should have used boost". I'm trying to do this without boost to get used to threads before moving onto other libraries.

    Read the article

  • Profile creation process stuck halfway Websphere

    - by ngubk
    I'm creating a cell profile on Linux Mint 12 , WAS 8.0 Network Deployment Trial. But using manageProfiles.sh or Profile Management Tool, I can not create any profile (cell, application ...). When I check the log file, the profile creation process is always stop halfway (does not show any error, just stuck there). The log is always like this <record> <date>2012-11-02T04:11:15</date> <millis>1351847475108</millis> <sequence>2985</sequence> <logger>com.ibm.ws.install.configmanager.actionengine.ant.utils.ANTLogToCmtLogAdapter</logger> <level>INFO</level> <class>com.ibm.ws.install.configmanager.actionengine.ant.utils.ANTLogToCmtLogAdapter</class> <method>messageLogged</method> <thread>0</thread> <message>replacing value for user.install.root (null) with (/opt/IBM/WebSphere/AppServer/profiles)</message> </record> <record> <date>2012-11-02T04:11:15</date> <millis>1351847475108</millis> <sequence>2986</sequence> <logger>com.ibm.ws.install.configmanager.actionengine.ant.utils.ANTLogToCmtLogAdapter</logger> <level>INFO</level> <class>com.ibm.ws.install.configmanager.actionengine.ant.utils.ANTLogToCmtLogAdapter</class> <method>messageLogged</method> <thread>0</thread> <message>replacing value for was.install.root (/opt/IBM/WebSphere/AppServer) with (/opt/IBM/WebSphere/AppServer)</message> </record> <record> <date>2012-11-02T04:11:15</date> <millis>1351847475108</millis> <sequence>2987</sequence> <logger>com.ibm.ws.install.configmanager.actionengine.ant.utils.ANTLogToCmtLogAdapter</logger> <level>INFO</level> <class>com.ibm.ws.install.configmanager.actionengine.ant.utils.ANTLogToCmtLogAdapter</class> <method>messageLogged</method> <thread>0</thread> <message>replacing value for was.repository.root (null) with (/opt/IBM/WebSphere/AppServer/profiles/config)</message> </record> <record> <date>2012-11-02T04:11:15</date> <millis>1351847475108</millis> <sequence>2988</sequence> <logger>com.ibm.ws.install.configmanager.actionengine.ant.utils.ANTLogToCmtLogAdapter</logger> <level>INFO</level> <class>com.ibm.ws.install.configmanager.actionengine.ant.utils.ANTLogToCmtLogAdapter</class> <method>messageLogged</method> <thread>0</thread> <message>replacing value for com.ibm.ws.scripting.wsadminprops (null) with (/opt/IBM/WebSphere/AppServer/profiles/properties/wsadmin.properties)</message> </record> <record> <date>2012-11-02T04:11:15</date> <millis>1351847475120</millis> <sequence>2989</sequence> <logger>com.ibm.ws.install.configmanager.actionengine.ant.utils.ANTLogToCmtLogAdapter</logger> <level>INFO</level> <class>com.ibm.ws.install.configmanager.actionengine.ant.utils.ANTLogToCmtLogAdapter</class> <method>messageLogged</method> <thread>0</thread> <message>Resetting listener available status to: false</message> </record> <record> <date>2012-11-02T04:11:15</date> <millis>1351847475121</millis> <sequence>2990</sequence> <logger>com.ibm.ws.install.configmanager.actionengine.ant.utils.ANTLogToCmtLogAdapter</logger> <level>INFO</level> <class>com.ibm.ws.install.configmanager.actionengine.ant.utils.ANTLogToCmtLogAdapter</class> <method>messageLogged</method> <thread>0</thread> <message>setting wsadmin requester timeouts</message> </record> <record> <date>2012-11-02T04:11:15</date> <millis>1351847475128</millis> <sequence>2991</sequence> <logger>com.ibm.ws.install.configmanager.actionengine.ant.utils.ANTLogToCmtLogAdapter</logger> <level>INFO</level> <class>com.ibm.ws.install.configmanager.actionengine.ant.utils.ANTLogToCmtLogAdapter</class> <method>messageLogged</method> <thread>0</thread> <message>wsadmin requester retry count = 240000, initialization retry count = 12000, shutdown retry count = 12000</message> </record> <record> <date>2012-11-02T04:11:15</date> <millis>1351847475128</millis> <sequence>2992</sequence> <logger>com.ibm.ws.install.configmanager.actionengine.ant.utils.ANTLogToCmtLogAdapter</logger> <level>INFO</level> <class>com.ibm.ws.install.configmanager.actionengine.ant.utils.ANTLogToCmtLogAdapter</class> <method>messageLogged</method> <thread>0</thread> <message>Checking for wsadmin listener initialization</message> </record>

    Read the article

  • Android edtftpj/PRo SFTP heap worker problem

    - by Mr. Kakakuwa Bird
    Hi I am using edtftpj-pro3.1 trial copy in my android app to make SFTP connection with the server. After few connections with the server with 5-6 file transfers, my app is crashing with following exception. Is it causing the problem or what could be the problem?? I tried setParallelMode(false) in SSHFTPClient, but it is not working. Exception i'm getting is, 05-31 18:28:12.661: ERROR/dalvikvm(589): HeapWorker is wedged: 10173ms spent inside Lcom/enterprisedt/net/j2ssh/sftp/SftpFileInputStream;.finalize()V 05-31 18:28:12.661: INFO/dalvikvm(589): DALVIK THREADS: 05-31 18:28:12.661: INFO/dalvikvm(589): "main" prio=5 tid=3 WAIT 05-31 18:28:12.661: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=N obj=0x4001b260 self=0xbd18 05-31 18:28:12.661: INFO/dalvikvm(589): | sysTid=589 nice=0 sched=0/0 cgrp=default handle=-1343993192 05-31 18:28:12.661: INFO/dalvikvm(589): at java.lang.Object.wait(Native Method) 05-31 18:28:12.661: INFO/dalvikvm(589): - waiting on <0x122d70 (a android.os.MessageQueue) 05-31 18:28:12.661: INFO/dalvikvm(589): at java.lang.Object.wait(Object.java:288) 05-31 18:28:12.661: INFO/dalvikvm(589): at android.os.MessageQueue.next(MessageQueue.java:148) 05-31 18:28:12.661: INFO/dalvikvm(589): at android.os.Looper.loop(Looper.java:110) 05-31 18:28:12.661: INFO/dalvikvm(589): at android.app.ActivityThread.main(ActivityThread.java:4363) 05-31 18:28:12.661: INFO/dalvikvm(589): at java.lang.reflect.Method.invokeNative(Native Method) 05-31 18:28:12.661: INFO/dalvikvm(589): at java.lang.reflect.Method.invoke(Method.java:521) 05-31 18:28:12.661: INFO/dalvikvm(589): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 05-31 18:28:12.661: INFO/dalvikvm(589): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 05-31 18:28:12.661: INFO/dalvikvm(589): at dalvik.system.NativeStart.main(Native Method) 05-31 18:28:12.671: INFO/dalvikvm(589): "Transport protocol 1" daemon prio=5 tid=29 NATIVE 05-31 18:28:12.671: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=N obj=0x44774768 self=0x3a7938 05-31 18:28:12.671: INFO/dalvikvm(589): | sysTid=605 nice=0 sched=0/0 cgrp=default handle=3834600 05-31 18:28:12.671: INFO/dalvikvm(589): at org.apache.harmony.luni.platform.OSNetworkSystem.receiveStreamImpl(Native Method) 05-31 18:28:12.671: INFO/dalvikvm(589): at org.apache.harmony.luni.platform.OSNetworkSystem.receiveStream(OSNetworkSystem.java:478) 05-31 18:28:12.671: INFO/dalvikvm(589): at org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:565) 05-31 18:28:12.671: INFO/dalvikvm(589): at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:87) 05-31 18:28:12.671: INFO/dalvikvm(589): at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:67) 05-31 18:28:12.671: INFO/dalvikvm(589): at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:157) 05-31 18:28:12.671: INFO/dalvikvm(589): at java.io.BufferedInputStream.read(BufferedInputStream.java:346) 05-31 18:28:12.671: INFO/dalvikvm(589): at java.io.BufferedInputStream.read(BufferedInputStream.java:341) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.transport.A.A((null):-1) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.transport.A.B((null):-1) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon.processMessages((null):-1) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon.startBinaryPacketProtocol((null):-1) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon.run((null):-1) 05-31 18:28:12.671: INFO/dalvikvm(589): at java.lang.Thread.run(Thread.java:1096) 05-31 18:28:12.671: INFO/dalvikvm(589): "StreamFrameSender" prio=5 tid=27 TIMED_WAIT 05-31 18:28:12.671: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=N obj=0x44750a60 self=0x3964d8 05-31 18:28:12.671: INFO/dalvikvm(589): | sysTid=603 nice=0 sched=0/0 cgrp=default handle=3761648 05-31 18:28:12.671: INFO/dalvikvm(589): at java.lang.Object.wait(Native Method) 05-31 18:28:12.671: INFO/dalvikvm(589): - waiting on <0x399478 (a com.corventis.gateway.ppp.StreamFrameSender) 05-31 18:28:12.671: INFO/dalvikvm(589): at java.lang.Object.wait(Object.java:326) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.corventis.gateway.ppp.StreamFrameSender.run(StreamFrameSender.java:154) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.corventis.gateway.util.MonitoredRunnable.run(MonitoredRunnable.java:41) 05-31 18:28:12.671: INFO/dalvikvm(589): at java.lang.Thread.run(Thread.java:1096) 05-31 18:28:12.671: INFO/dalvikvm(589): "SftpActiveWorker" prio=5 tid=25 TIMED_WAIT 05-31 18:28:12.671: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=N obj=0x447522b0 self=0x398e00 05-31 18:28:12.671: INFO/dalvikvm(589): | sysTid=604 nice=0 sched=0/0 cgrp=default handle=3762704 05-31 18:28:12.671: INFO/dalvikvm(589): at java.lang.Object.wait(Native Method) 05-31 18:28:12.671: INFO/dalvikvm(589): - waiting on <0x3962d8 (a com.corventis.gateway.hostcommunicator.SftpActiveWorker) 05-31 18:28:12.671: INFO/dalvikvm(589): at java.lang.Object.wait(Object.java:326) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.corventis.gateway.hostcommunicator.SftpActiveWorker.run(SftpActiveWorker.java:151) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.corventis.gateway.util.MonitoredRunnable.run(MonitoredRunnable.java:41) 05-31 18:28:12.671: INFO/dalvikvm(589): at java.lang.Thread.run(Thread.java:1096) 05-31 18:28:12.671: INFO/dalvikvm(589): "Thread-12" prio=5 tid=23 NATIVE 05-31 18:28:12.671: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=N obj=0x4474aca8 self=0x115690 05-31 18:28:12.671: INFO/dalvikvm(589): | sysTid=602 nice=0 sched=0/0 cgrp=default handle=878120 05-31 18:28:12.671: INFO/dalvikvm(589): at android.bluetooth.BluetoothSocket.acceptNative(Native Method) 05-31 18:28:12.681: INFO/dalvikvm(589): at android.bluetooth.BluetoothSocket.accept(BluetoothSocket.java:287) 05-31 18:28:12.681: INFO/dalvikvm(589): at android.bluetooth.BluetoothServerSocket.accept(BluetoothServerSocket.java:105) 05-31 18:28:12.681: INFO/dalvikvm(589): at android.bluetooth.BluetoothServerSocket.accept(BluetoothServerSocket.java:91) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.bluetooth.BluetoothManager.openPort(BluetoothManager.java:215) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.bluetooth.BluetoothManager.open(BluetoothManager.java:84) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.patchcommunicator.PatchCommunicator.open(PatchCommunicator.java:123) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.patchcommunicator.PatchCommunicatorRunnable.run(PatchCommunicatorRunnable.java:134) 05-31 18:28:12.681: INFO/dalvikvm(589): at java.lang.Thread.run(Thread.java:1096) 05-31 18:28:12.681: INFO/dalvikvm(589): "HfGatewayApplication" prio=5 tid=21 RUNNABLE 05-31 18:28:12.681: INFO/dalvikvm(589): | group="main" sCount=0 dsCount=0 s=N obj=0x4472d9b0 self=0x120928 05-31 18:28:12.681: INFO/dalvikvm(589): | sysTid=601 nice=0 sched=0/0 cgrp=default handle=1264672 05-31 18:28:12.681: INFO/dalvikvm(589): at com.jcraft.jzlib.Deflate.deflateInit2(Deflate.java:~1361) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.jcraft.jzlib.Deflate.deflateInit(Deflate.java:1316) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.jcraft.jzlib.ZStream.deflateInit(ZStream.java:127) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.jcraft.jzlib.ZStream.deflateInit(ZStream.java:120) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.jcraft.jzlib.ZOutputStream.(ZOutputStream.java:62) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.zipfile.ZipStorer.addStream(ZipStorer.java:211) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.zipfile.ZipStorer.createZip(ZipStorer.java:127) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.hostcommunicator.HostCommunicator.scanAndCompress(HostCommunicator.java:453) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.hostcommunicator.HostCommunicator.doWork(HostCommunicator.java:1434) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.hf.HfGatewayApplication.doWork(HfGatewayApplication.java:621) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.hf.HfGatewayApplication.run(HfGatewayApplication.java:546) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.util.MonitoredRunnable.run(MonitoredRunnable.java:41) 05-31 18:28:12.681: INFO/dalvikvm(589): at java.lang.Thread.run(Thread.java:1096) 05-31 18:28:12.681: INFO/dalvikvm(589): "Thread-10" prio=5 tid=19 TIMED_WAIT 05-31 18:28:12.681: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=N obj=0x447287f8 self=0x1451b8 05-31 18:28:12.681: INFO/dalvikvm(589): | sysTid=598 nice=0 sched=0/0 cgrp=default handle=1331920 05-31 18:28:12.681: INFO/dalvikvm(589): at java.lang.VMThread.sleep(Native Method) 05-31 18:28:12.681: INFO/dalvikvm(589): at java.lang.Thread.sleep(Thread.java:1306) 05-31 18:28:12.681: INFO/dalvikvm(589): at java.lang.Thread.sleep(Thread.java:1286) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.util.Watchdog.run(Watchdog.java:167) 05-31 18:28:12.681: INFO/dalvikvm(589): at java.lang.Thread.run(Thread.java:1096) 05-31 18:28:12.681: INFO/dalvikvm(589): "Thread-9" prio=5 tid=17 RUNNABLE 05-31 18:28:12.681: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=Y obj=0x44722c90 self=0x114e20 05-31 18:28:12.681: INFO/dalvikvm(589): | sysTid=597 nice=0 sched=0/0 cgrp=default handle=1200048 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.time.Time.currentTimeMillis(Time.java:~77) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.patchcommunicator.PatchCommunicatorState$1.run(PatchCommunicatorState.java:27) 05-31 18:28:12.681: INFO/dalvikvm(589): "Thread-8" prio=5 tid=15 RUNNABLE 05-31 18:28:12.681: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=Y obj=0x44722430 self=0x124dd0 05-31 18:28:12.681: INFO/dalvikvm(589): | sysTid=596 nice=0 sched=0/0 cgrp=default handle=1199848 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.time.Time.currentTimeMillis(Time.java:~80) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.hostcommunicator.HostCommunicatorState$1.run(HostCommunicatorState.java:35) 05-31 18:28:12.681: INFO/dalvikvm(589): "Binder Thread #2" prio=5 tid=13 NATIVE 05-31 18:28:12.681: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=N obj=0x4471ccc0 self=0x149b60 05-31 18:28:12.681: INFO/dalvikvm(589): | sysTid=595 nice=0 sched=0/0 cgrp=default handle=1317992 05-31 18:28:12.681: INFO/dalvikvm(589): at dalvik.system.NativeStart.run(Native Method) 05-31 18:28:12.681: INFO/dalvikvm(589): "Binder Thread #1" prio=5 tid=11 NATIVE 05-31 18:28:12.681: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=N obj=0x447159a8 self=0x123298 05-31 18:28:12.681: INFO/dalvikvm(589): | sysTid=594 nice=0 sched=0/0 cgrp=default handle=1164896 05-31 18:28:12.681: INFO/dalvikvm(589): at dalvik.system.NativeStart.run(Native Method) 05-31 18:28:12.691: INFO/dalvikvm(589): "JDWP" daemon prio=5 tid=9 VMWAIT 05-31 18:28:12.691: INFO/dalvikvm(589): | group="system" sCount=1 dsCount=0 s=N obj=0x4470f2a0 self=0x141a90 05-31 18:28:12.691: INFO/dalvikvm(589): | sysTid=593 nice=0 sched=0/0 cgrp=default handle=1316864 05-31 18:28:12.691: INFO/dalvikvm(589): at dalvik.system.NativeStart.run(Native Method) 05-31 18:28:12.691: INFO/dalvikvm(589): "Signal Catcher" daemon prio=5 tid=7 VMWAIT 05-31 18:28:12.691: INFO/dalvikvm(589): | group="system" sCount=1 dsCount=0 s=N obj=0x4470f1e8 self=0x124970 05-31 18:28:12.691: INFO/dalvikvm(589): | sysTid=592 nice=0 sched=0/0 cgrp=default handle=1316800 05-31 18:28:12.691: INFO/dalvikvm(589): at dalvik.system.NativeStart.run(Native Method) 05-31 18:28:12.691: INFO/dalvikvm(589): "HeapWorker" daemon prio=5 tid=5 MONITOR 05-31 18:28:12.691: INFO/dalvikvm(589): | group="system" sCount=1 dsCount=0 s=N obj=0x431b4550 self=0x141670 05-31 18:28:12.691: INFO/dalvikvm(589): | sysTid=591 nice=0 sched=0/0 cgrp=default handle=1316400 05-31 18:28:12.691: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.sftp.SftpSubsystemClient.closeHandle((null):~-1) 05-31 18:28:12.691: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.sftp.SftpSubsystemClient.closeFile((null):-1) 05-31 18:28:12.691: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.sftp.SftpFile.close((null):-1) 05-31 18:28:12.691: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.sftp.SftpFileInputStream.close((null):-1) 05-31 18:28:12.691: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.sftp.SftpFileInputStream.finalize((null):-1) 05-31 18:28:12.691: INFO/dalvikvm(589): at dalvik.system.NativeStart.run(Native Method) 05-31 18:28:12.691: ERROR/dalvikvm(589): VM aborting 05-31 18:28:12.801: INFO/DEBUG(49): * ** * ** * ** * ** * ** * 05-31 18:28:12.801: INFO/DEBUG(49): Build fingerprint: 'google/passion/passion/mahimahi:2.1-update1/ERE27/24178:user/release-keys' 05-31 18:28:12.801: INFO/DEBUG(49): pid: 589, tid: 601 com.corventis.gateway.hf <<< 05-31 18:28:12.801: INFO/DEBUG(49): signal 11 (SIGSEGV), fault addr deadd00d 05-31 18:28:12.801: INFO/DEBUG(49): r0 00000026 r1 afe13329 r2 afe13329 r3 00000000 05-31 18:28:12.801: INFO/DEBUG(49): r4 ad081f50 r5 400091e8 r6 009b3a6a r7 00000000 05-31 18:28:12.801: INFO/DEBUG(49): r8 000002e8 r9 ad082ba0 10 ad082ba0 fp 00000000 05-31 18:28:12.801: INFO/DEBUG(49): ip deadd00d sp 46937c58 lr afe14373 pc ad035b4c cpsr 20000030 05-31 18:28:12.851: INFO/DEBUG(49): #00 pc 00035b4c /system/lib/libdvm.so 05-31 18:28:12.861: INFO/DEBUG(49): #01 pc 00044d7c /system/lib/libdvm.so 05-31 18:28:12.861: INFO/DEBUG(49): #02 pc 000162e4 /system/lib/libdvm.so 05-31 18:28:12.861: INFO/DEBUG(49): #03 pc 00016b60 /system/lib/libdvm.so 05-31 18:28:12.861: INFO/DEBUG(49): #04 pc 00016ce0 /system/lib/libdvm.so 05-31 18:28:12.861: INFO/DEBUG(49): #05 pc 00057b64 /system/lib/libdvm.so 05-31 18:28:12.861: INFO/DEBUG(49): #06 pc 00057cc0 /system/lib/libdvm.so 05-31 18:28:12.871: INFO/DEBUG(49): #07 pc 00057dd4 /system/lib/libdvm.so 05-31 18:28:12.871: INFO/DEBUG(49): #08 pc 00012ffc /system/lib/libdvm.so 05-31 18:28:12.871: INFO/DEBUG(49): #09 pc 00019338 /system/lib/libdvm.so 05-31 18:28:12.871: INFO/DEBUG(49): #10 pc 00018804 /system/lib/libdvm.so 05-31 18:28:12.871: INFO/DEBUG(49): #11 pc 0004eed0 /system/lib/libdvm.so 05-31 18:28:12.871: INFO/DEBUG(49): #12 pc 0004eef8 /system/lib/libdvm.so 05-31 18:28:12.871: INFO/DEBUG(49): #13 pc 000426d4 /system/lib/libdvm.so 05-31 18:28:12.881: INFO/DEBUG(49): #14 pc 0000fd74 /system/lib/libc.so 05-31 18:28:12.881: INFO/DEBUG(49): #15 pc 0000f840 /system/lib/libc.so 05-31 18:28:12.881: INFO/DEBUG(49): code around pc: 05-31 18:28:12.881: INFO/DEBUG(49): ad035b3c 58234808 b1036b9b f8df4798 2026c01c 05-31 18:28:12.881: INFO/DEBUG(49): ad035b4c 0000f88c ef52f7d8 0004c428 fffe631c 05-31 18:28:12.881: INFO/DEBUG(49): ad035b5c fffe94f4 000002f8 deadd00d f8dfb40e 05-31 18:28:12.881: INFO/DEBUG(49): code around lr: 05-31 18:28:12.881: INFO/DEBUG(49): afe14360 686768a5 f9b5e008 b120000c 46289201 05-31 18:28:12.881: INFO/DEBUG(49): afe14370 9a014790 35544306 37fff117 6824d5f3 05-31 18:28:12.881: INFO/DEBUG(49): afe14380 d1ed2c00 bdfe4630 00026ab0 000000b4 05-31 18:28:12.881: INFO/DEBUG(49): stack: 05-31 18:28:12.881: INFO/DEBUG(49): 46937c18 00000015 05-31 18:28:12.881: INFO/DEBUG(49): 46937c1c afe13359 /system/lib/libc.so 05-31 18:28:12.881: INFO/DEBUG(49): 46937c20 afe3b02c /system/lib/libc.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c24 afe3afd8 /system/lib/libc.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c28 00000000 05-31 18:28:12.891: INFO/DEBUG(49): 46937c2c afe14373 /system/lib/libc.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c30 afe13329 /system/lib/libc.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c34 afe13329 /system/lib/libc.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c38 afe13380 /system/lib/libc.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c3c ad081f50 /system/lib/libdvm.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c40 400091e8 /dev/ashmem/mspace/dalvik-heap/zygote/0 (deleted) 05-31 18:28:12.891: INFO/DEBUG(49): 46937c44 009b3a6a 05-31 18:28:12.891: INFO/DEBUG(49): 46937c48 00000000 05-31 18:28:12.891: INFO/DEBUG(49): 46937c4c afe1338d /system/lib/libc.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c50 df002777 05-31 18:28:12.891: INFO/DEBUG(49): 46937c54 e3a070ad 05-31 18:28:12.891: INFO/DEBUG(49): #00 46937c58 ad06f573 /system/lib/libdvm.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c5c ad044d81 /system/lib/libdvm.so 05-31 18:28:12.891: INFO/DEBUG(49): #01 46937c60 000027bd 05-31 18:28:12.891: INFO/DEBUG(49): 46937c64 00000000 05-31 18:28:12.891: INFO/DEBUG(49): 46937c68 463b6ab4 /data/dalvik-cache/data@[email protected]@classes.dex 05-31 18:28:12.891: INFO/DEBUG(49): 46937c6c 463d1ecf /data/dalvik-cache/data@[email protected]@classes.dex 05-31 18:28:12.891: INFO/DEBUG(49): 46937c70 00140450 [heap] 05-31 18:28:12.891: INFO/DEBUG(49): 46937c74 ad041d2b /system/lib/libdvm.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c78 ad082f2c /system/lib/libdvm.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c7c ad06826c /system/lib/libdvm.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c80 00140450 [heap] 05-31 18:28:12.891: INFO/DEBUG(49): 46937c84 00000000 05-31 18:28:12.891: INFO/DEBUG(49): 46937c88 000002f8 05-31 18:28:12.891: INFO/DEBUG(49): 46937c8c 400091e8 /dev/ashmem/mspace/dalvik-heap/zygote/0 (deleted) 05-31 18:28:12.891: INFO/DEBUG(49): 46937c90 ad081f50 /system/lib/libdvm.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c94 000002f8 05-31 18:28:12.891: INFO/DEBUG(49): 46937c98 00002710 05-31 18:28:12.891: INFO/DEBUG(49): 46937c9c ad0162e8 /system/lib/libdvm.so Thanks & Regards,

    Read the article

  • .NET 1.0 ThreadPool Question

    - by dotnet-practitioner
    I am trying to spawn a thread to take care of DoWork task that should take less than 3 seconds. Inside DoWork its taking 15 seconds. I want to abort DoWork and transfer the control back to main thread. I have copied the code as follows and its not working. Instead of aborting DoWork, it still finishes DoWork and then transfers the control back to main thread. What am I doing wrong? class Class1 { /// <summary> /// The main entry point for the application. /// </summary> /// private static System.Threading.ManualResetEvent[] resetEvents; [STAThread] static void Main(string[] args) { resetEvents = new ManualResetEvent[1]; int i = 0; resetEvents[i] = new ManualResetEvent(false); ThreadPool.QueueUserWorkItem(new WaitCallback(DoWork),(object)i); Thread.CurrentThread.Name = "main thread"; Console.WriteLine("[{0}] waiting in the main method", Thread.CurrentThread.Name); DateTime start = DateTime.Now; DateTime end ; TimeSpan span = DateTime.Now.Subtract(start); //abort dowork method if it takes more than 3 seconds //and transfer control to the main thread. do { if (span.Seconds < 3) WaitHandle.WaitAll(resetEvents); else resetEvents[0].Set(); end = DateTime.Now; span = end.Subtract(start); }while (span.Seconds < 2); Console.WriteLine(span.Seconds); Console.WriteLine("[{0}] all done in the main method",Thread.CurrentThread.Name); Console.ReadLine(); } static void DoWork(object o) { int index = (int)o; Thread.CurrentThread.Name = "do work thread"; //simulate heavy duty work. Thread.Sleep(15000); //work is done.. resetEvents[index].Set(); Console.WriteLine("[{0}] do work finished",Thread.CurrentThread.Name); } }

    Read the article

  • Sending custom PyQt signals?

    - by Enfors
    I'm practicing PyQt and (Q)threads by making a simple Twitter client. I have two Qthreads. Main/GUI thread. Twitter fetch thread - fetches data from Twitter every X minutes. So, every X minutes my Twitter thread downloads a new set of status updates (a Python list). I want to hand this list over to the Main/GUI thread, so that it can update the window with these statuses. I'm assuming that I should be using the signal / slot system to transfer the "statuses" Python list from the Twitter thread, to the Main/GUI thread. So, my question is twofold: How do I send the statuses from the Twitter thread? How do I receive them in the Main/GUI thread? As far as I can tell, PyQt can by default only send PyQt-objects via signals / slots. I think I'm supposed to somehow register a custom signal which I can then send, but the documentation on this that I've found is very unclear to a newbie like me. I have a PyQt book on order, but it won't arrive in another week, and I don't want to wait until then. :-) I'm using PyQt 4.6-1 on Ubuntu Update: This is an excert from the code that doesn't work. First, I try to "connect" the signal ("newStatuses", a name I just made up) to the function self.update_tweet_list in the Main/GUI thread: QtCore.QObject.connect(self.twit_in, QtCore.SIGNAL("newStatuses (statuses)"), self.update_tweet_list) Then, in the Twitter thread, I do this: self.emit(SIGNAL("newStatuses (statuses)"), statuses) When this line is called, I get the following message: QObject::connect: Cannot queue arguments of type 'statuses' (Make sure 'statuses' is registered using qRegisterMetaType().) I did a search for qRegisterMetaType() but I didn't find anything relating to Python that I could understand.

    Read the article

  • Google App Engine: Unit testing concurrent access to memcache

    - by Phuong Nguyen de ManCity fan
    Would you guys show me a way to simulating concurrent access to memcache on Google App Engine? I'm trying with LocalServiceTestHelpers and threads but don't have any luck. Every time I try to access Memcache within a thread, then I get this error: ApiProxy$CallNotFoundException: The API package 'memcache' or call 'Increment()' was not found I guess that the testing library of GAE SDK tried to mimic the real environment and thus setup the environment for only one thread (the thread that running the test) which cannot be seen by other thread. Here is a piece of code that can reproduce the problem package org.seamoo.cache.memcacheImpl; import org.testng.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import com.google.appengine.api.memcache.MemcacheService; import com.google.appengine.api.memcache.MemcacheServiceFactory; import com.google.appengine.tools.development.testing.LocalMemcacheServiceTestConfig; import com.google.appengine.tools.development.testing.LocalServiceTestHelper; public class MemcacheTest { LocalServiceTestHelper helper; public MemcacheTest() { LocalMemcacheServiceTestConfig memcacheConfig = new LocalMemcacheServiceTestConfig(); helper = new LocalServiceTestHelper(memcacheConfig); } /** * */ @BeforeMethod public void setUp() { helper.setUp(); } /** * @see LocalServiceTest#tearDown() */ @AfterMethod public void tearDown() { helper.tearDown(); } @Test public void memcacheConcurrentAccess() throws InterruptedException { final MemcacheService service = MemcacheServiceFactory.getMemcacheService(); Runnable runner = new Runnable() { @Override public void run() { // TODO Auto-generated method stub service.increment("test-key", 1L, 1L); try { Thread.sleep(200L); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } service.increment("test-key", 1L, 1L); } }; Thread t1 = new Thread(runner); Thread t2 = new Thread(runner); t1.start(); t2.start(); while (t1.isAlive()) { Thread.sleep(100L); } Assert.assertEquals((Long) (service.get("test-key")), new Long(4L)); } }

    Read the article

  • How to log correct context with Threadpool threads using log4net?

    - by myotherme
    I am trying to find a way to log useful context from a bunch of threads. The problem is that a lot of code is dealt with on Events that are arriving via threadpool threads (as far as I can tell) so their names are not in relation to any context. The problem can be demonstrated with the following code: class Program { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); static void Main(string[] args) { new Thread(TestThis).Start("ThreadA"); new Thread(TestThis).Start("ThreadB"); Console.ReadLine(); } private static void TestThis(object name) { var nameStr = (string)name; Thread.CurrentThread.Name = nameStr; log4net.ThreadContext.Properties["ThreadContext"] = nameStr; log4net.LogicalThreadContext.Properties["LogicalThreadContext"] = nameStr; log.Debug("From Thread itself"); ThreadPool.QueueUserWorkItem(x => log.Debug("From threadpool Thread: " + nameStr)); } } The Conversion pattern is: %date [%thread] %-5level %logger [%property] - %message%newline The output is like so: 2010-05-21 15:08:02,357 [ThreadA] DEBUG LogicalContextTest.Program [{LogicalThreadContext=ThreadA, log4net:HostName=xxx, ThreadContext=ThreadA}] - From Thread itself 2010-05-21 15:08:02,357 [ThreadB] DEBUG LogicalContextTest.Program [{LogicalThreadContext=ThreadB, log4net:HostName=xxx, ThreadContext=ThreadB}] - From Thread itself 2010-05-21 15:08:02,404 [7] DEBUG LogicalContextTest.Program [{log4net:HostName=xxx}] - From threadpool Thread: ThreadA 2010-05-21 15:08:02,420 [16] DEBUG LogicalContextTest.Program [{log4net:HostName=xxx}] - From threadpool Thread: ThreadB As you can see the last two rows have no Names of useful information to distinguish the 2 threads, other than manually adding the name to the message (which I want to avoid). How can I get the Name/Context into the log for the threadpool threads without adding it to the message at every call?

    Read the article

< Previous Page | 53 54 55 56 57 58 59 60 61 62 63 64  | Next Page >