Search Results

Search found 5945 results on 238 pages for 'green threads'.

Page 18/238 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Generate colors between red and green for a power meter?

    - by Simucal
    I'm writing a java game and I want to implement a power meter for how hard you are going to shoot something. I need to write a function that takes a int between 0 - 100, and based on how high that number is, it will return a color between Green (0 on the power scale) and Red (100 on the power scale). Similar to how volume controls work: What operation do I need to do on the Red, Green, and Blue components of a color to generate the colors between Green and Red? So, I could run say, getColor(80) and it will return an orangish color (its values in R, G, B) or getColor(10) which will return a more Green/Yellow rgb value. I know I need to increase components of the R, G, B values for a new color, but I don't know specifically what goes up or down as the colors shift from Green-Red. Progress: I ended up using HSV/HSB color space because I liked the gradiant better (no dark browns in the middle). The function I used was (in java): public Color getColor(double power) { double H = power * 0.4; // Hue (note 0.4 = Green, see huge chart below) double S = 0.9; // Saturation double B = 0.9; // Brightness return Color.getHSBColor((float)H, (float)S, (float)B); } Where "power" is a number between 0.0 and 1.0. 0.0 will return a bright red, 1.0 will return a bright green. Java Hue Chart: Thanks everyone for helping me with this!

    Read the article

  • How to use pthread_atfork() and pthread_once() to reinitialize mutexes in child processes

    - by Blair Zajac
    We have a C++ shared library that uses ZeroC's Ice library for RPC and unless we shut down Ice's runtime, we've observed child processes hanging on random mutexes. The Ice runtime starts threads, has many internal mutexes and keeps open file descriptors to servers. Additionally, we have a few of mutexes of our own to protect our internal state. Our shared library is used by hundreds of internal applications so we don't have control over when the process calls fork(), so we need a way to safely shutdown Ice and lock our mutexes while the process forks. Reading the POSIX standard on pthread_atfork() on handling mutexes and internal state: Alternatively, some libraries might have been able to supply just a child routine that reinitializes the mutexes in the library and all associated states to some known value (for example, what it was when the image was originally executed). This approach is not possible, though, because implementations are allowed to fail *_init() and *_destroy() calls for mutexes and locks if the mutex or lock is still locked. In this case, the child routine is not able to reinitialize the mutexes and locks. On Linux, the this test C program returns EPERM from pthread_mutex_unlock() in the child pthread_atfork() handler. Linux requires adding _NP to the PTHREAD_MUTEX_ERRORCHECK macro for it to compile. This program is linked from this good thread. Given that it's technically not safe or legal to unlock or destroy a mutex in the child, I'm thinking it's better to have pointers to mutexes and then have the child make new pthread_mutex_t on the heap and leave the parent's mutexes alone, thereby having a small memory leak. The only issue is how to reinitialize the state of the library and I'm thinking of reseting a pthread_once_t. Maybe because POSIX has an initializer for pthread_once_t that it can be reset to its initial state. #include <pthread.h> #include <stdlib.h> #include <string.h> static pthread_once_t once_control = PTHREAD_ONCE_INIT; static pthread_mutex_t *mutex_ptr = 0; static void setup_new_mutex() { mutex_ptr = malloc(sizeof(*mutex_ptr)); pthread_mutex_init(mutex_ptr, 0); } static void prepare() { pthread_mutex_lock(mutex_ptr); } static void parent() { pthread_mutex_unlock(mutex_ptr); } static void child() { // Reset the once control. pthread_once_t once = PTHREAD_ONCE_INIT; memcpy(&once_control, &once, sizeof(once_control)); setup_new_mutex(); } static void init() { setup_new_mutex(); pthread_atfork(&prepare, &parent, &child); } int my_library_call(int arg) { pthread_once(&once_control, &init); pthread_mutex_lock(mutex_ptr); // Do something here that requires the lock. int result = 2*arg; pthread_mutex_unlock(mutex_ptr); return result; } In the above sample in the child() I only reset the pthread_once_t by making a copy of a fresh pthread_once_t initialized with PTHREAD_ONCE_INIT. A new pthread_mutex_t is only created when the library function is invoked in the child process. This is hacky but maybe the best way of dealing with this skirting the standards. If the pthread_once_t contains a mutex then the system must have a way of initializing it from its PTHREAD_ONCE_INIT state. If it contains a pointer to a mutex allocated on the heap than it'll be forced to allocate a new one and set the address in the pthread_once_t. I'm hoping it doesn't use the address of the pthread_once_t for anything special which would defeat this. Searching comp.programming.threads group for pthread_atfork() shows a lot of good discussion and how little the POSIX standards really provides to solve this problem. There's also the issue that one should only call async-signal-safe functions from pthread_atfork() handlers, and it appears the most important one is the child handler, where only a memcpy() is done. Does this work? Is there a better way of dealing with the requirements of our shared library?

    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

  • Perfmon: which counter identifies that threads are waiting?

    - by frankadelic
    While load testing an ASP.NET app, we find that the pages are taking 20-30 sec under heavy load. We suspect this is because the pages are waiting for database calls or web services. Is there a particular perfmon counter that can identify this sort of bottleneck on the web servers? CPU, Memory, and Disk are normal. Or must we use a tool other than perfmon to track down this bottleneck?

    Read the article

  • What if I can't make my unit test fail in "Red, Green, Refactor" of TDD?

    - by Joshua Harris
    So let's say that I have a test: @Test public void MoveY_MoveZero_DoesNotMove() { Point p = new Point(50.0, 50.0); p.MoveY(0.0); Assert.assertAreEqual(50.0, p.Y); } This test then causes me to create the class Point: public class Point { double X; double Y; public void MoveY(double yDisplace) { throw new NotYetImplementedException(); } } Ok. It fails. Good. Then I remove the exception and I get green. Great, but of course I need to test if it changes value. So I write a test that calls p.MoveY(10.0) and checks if p.Y is equal to 60.0. It fails, so then I change the function to look like so: public void MoveY(double yDisplace) { Y += yDisplace; } Great, now I have green again and I can move on. I've tested not moving and moving in the positive direction, so naturally I should test a negative value. The only problem with this test is that if I wrote the test correctly, then it doesn't fail at first. That means that I didn't fit the principle of "Red, Green, Refactor." Of course, This is a first-world problem of TDD, but getting a fail at first is helpful in that it shows that your test can fail. Otherwise this seemingly innocent test that is just passing for incorrect reasons could fail later because it was written wrong. That might not be a problem if it happened 5 minutes later, but what if it happens to the poor-sap that inheirited your code two years later. What he knows is that MoveY does not work with negative values because that is what the test is telling him. But, it really could work and just be a bug in the test. I don't think that would happen in this particular case because the code sample is so simple, but if it were a large complicated system that might not be the case. It seems crazy to say that I want to fail my tests, but that is an important step in TDD, for good reasons.

    Read the article

  • Green IT : Les entreprises de plus en plus interessées par le "smart bluiding", pour des bureaux plus économes en énergie

    Green IT : Les entreprises sont de plus en plus interessées par le "smart bluiding", des firmes comme Microsoft, Google, IBM ou Cisco pourraient s'affronter sur ce terrain Un nouveau concept fait son apparition et commence a attirer les convoitises dans le domaine de l'écologie numérique : les "smart building". En effet, dans le futur proche, la prochaine grande tendance en Green IT sera d'améliorer la consommation d'énergie des bâtiments où sont installés des bureaux. Une belle concurrence en perspective, entre les fabriquants de systèmes de contrôles des immeubles (mais aussi les vendeurs d'éclairages, etc.) et les entreprises informatiques. Ces prédictions émanent d'un rapport re...

    Read the article

  • PLINQ delayed execution

    - by tbischel
    I'm trying to understand how parallelism might work using PLINQ, given delayed execution. Here is a simple example. string[] words = { "believe", "receipt", "relief", "field" }; bool result = words.AsParallel().Any(w => w.Contains("ei")); With LINQ, I would expect the execution to reach the "receipt" value and return true, without executing the query for rest of the values. If we do this in parallel, the evaluation of "relief" may have began before the result of "receipt" has returned. But once the query knows that "receipt" will cause a true result, will the other threads yield immediately? In my case, this is important because the "any" test may be very expensive, and I would want to free up the processors for execution of other tasks.

    Read the article

  • Why the following Java code has different outputs each time?

    - by Maxood
    I don't know about threads in Java. I like to know what is happening in this code because each time it runs, it produces a different output: public class TwoThreadsDemo{ public static void main(String[] args) { new SimpleThread("Java Programmer").start(); new SimpleThread("Java Programmer").start(); } } class SimpleThread extends Thread{ public SimpleThread(String str) { super(str); } public void run() { for (int i=0;i<10;i++) { System.out.println(i + " " + getName()); try { sleep((long)(Math.random()*1000)); } catch(InterruptedException e) { } } System.out.println("Done!" + getName()); } }

    Read the article

  • Spawning BackgroundWorkers

    - by washtik
    We have a business case that would be perfect for multiple BackgroundWorkers. As an example, we have a form with a "Save" button on it. Normally we would run all the save commands (Save is an example) synchronously and then close the form. We would like to now split the work onto separate threads using backgroundworker. We will loop through each "Save" required (could be many and/or different number of commands that need executing) creating a BackgroundWorker for each command required. The question is ... how do we wait for ALL the BackgroundWorkers to complete before we close the form. We understand how to wait for a single BackgroundWorker to complete but when we have X number of BackgroundWorkers operating, how do we wait until all are complete before closing the UI form?

    Read the article

  • Boost Thread Hanging on _endthreadex

    - by FranticPedantic
    I think I am making a simple mistake, but since I noticed there are many boost experts here, I thought I would ask for help. I am trying to use boost threads(1_40) on windows xp. The main program loads a dll, starts the thread like so (note this is not in a class, the static does not mean static to a class but private to the file). static boost::thread network_thread; network_start() { // do network stuff until quit is signaled } DllClass::InitInstance() { network_thread = boost::thread(boost::bind<void>(network_start)); } DllClass::ExitInstance() { //signal quit (which works) //the following code is slightly verbose because I'm trying to figure out what's wrong try { if (network_thread.joinable() ) { network_thread.join(); } else { TRACE("Too late!"); } } catch (boost::thread_interrupted&) { TRACE("NET INTERRUPTED"); } } The problem is that the main thread is hanging on the join, and the network thread is hanging at the end of _endthreadex. What am I misunderstanding?

    Read the article

  • Effective thread Synchronization in C#

    - by n0vic3c0d3r
    I have a scenario where I need to search from many binary files (using keys) and combine the results (strings). Until now, I have been doing it in a for loop one file after the other. foreach (string file in FileSources.Keys) { aggregatedDefinitions.Append(DefinitionLookup(txtSearchWord.Text, file)); } Since this operation is very slow, I was thinking of using threads, so that I could do IO operations in parallel. Is threading the right way to go. If I use threading, how can I ensure that I get the results in the order I want. I haven't used Threading until now. It would be very helpful if you could suggest some materials/books that would help me solve my problem.

    Read the article

  • posix pthreads in c

    - by Codenotguru
    Iam new to c programming and needs some help. long *taskids[NUM_THREADS]; for(t=0; t<NUM_THREADS; t++) { taskids[t] = (long *) malloc(sizeof(long)); *taskids[t] = t; printf("Creating thread %ld\n", t); rc = pthread_create(&threads[t], NULL, PrintHello, (void *) taskids[t]); ... } This code fragment demonstrates how to pass a simple integer to each thread. The calling thread uses a unique data structure for each thread, insuring that each thread's argument remains intact throughout the program. Iam not able to understand how this is happening can somebody explain it??

    Read the article

  • No speed-up with useless printf's using OpenMP

    - by t2k32316
    I just wrote my first OpenMP program that parallelizes a simple for loop. I ran the code on my dual core machine and saw some speed up when going from 1 thread to 2 threads. However, I ran the same code on a school linux server and saw no speed-up. After trying different things, I finally realized that removing some useless printf statements caused the code to have significant speed-up. Below is the main part of the code that I parallelized: #pragma omp parallel for private(i) for(i = 2; i <= n; i++) { printf("useless statement"); prime[i-2] = is_prime(i); } I guess that the implementation of printf has significant overhead that OpenMP must be duplicating with each thread. What causes this overhead and why can OpenMP not overcome it?

    Read the article

  • Java process inputstream in thread

    - by Norbiprog
    Hi! I develop an Eclipse plugin and I have a problem My code is the following one: String run_pelda = "cmd.exe /C pelda.exe"; Runtime pelda_rt = Runtime.getRuntime(); Process pelda_proc = javacheckgen_rt.exec(run_pelda); And after I would like to read the inputstream: InputStream toolstr = tool_proc.getInputStream(); InputStreamReader r = new InputStreamReader(toolstr); BufferedReader in = new BufferedReader(r); But my new Eclipse instsnce doesn't work. I think I should do it in java threads, but unfortunatelly I don't know to use it correctly. Please give me some ideas!

    Read the article

  • Threads in WCF service

    - by dragonfly
    Hi, there is a piece of code: class WCFConsoleHostApp : IBank { private static int _instanceCounter; public WCFConsoleHostApp () { Interlocked.Increment(ref _instanceCounter); Console.WriteLine(string.Format("{0:T} Instance nr " + _instanceCounter + " created", DateTime.Now)); } private static int amount; static void Main(string[] args) { ServiceHost host = new ServiceHost(typeof(WCFConsoleHostApp)); host.Open(); Console.WriteLine("Host is running..."); Console.ReadLine(); } #region IBank Members BankOperationResult IBank.Put(int amount) { Console.WriteLine(string.Format("{0:00} {1}", Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.IsThreadPoolThread) + " Putting..."); WCFConsoleHostApp.amount += amount; Thread.Sleep(20000); Console.WriteLine(string.Format("{0:00} {1}", Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.IsThreadPoolThread) + " Putting done"); return new BankOperationResult { CurrentAmount = WCFConsoleHostApp.amount, Success = true }; } BankOperationResult IBank.Withdraw(int amount) { Console.WriteLine(string.Format("{0:00} {1}", Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.IsThreadPoolThread) + " Withdrawing..."); WCFConsoleHostApp.amount -= amount; Thread.Sleep(20000); Console.WriteLine(string.Format("{0:00} {1}", Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.IsThreadPoolThread) + " Withdrawing done"); return new BankOperationResult { CurrentAmount = WCFConsoleHostApp.amount, Success = true }; } #endregion } My test client application calls that service in 50 threads (service is PerCall). What I found very disturbing is when I added Thread.Sleep(20000) WCF creates one service instance per second using different thread from pool. When I remove Thread.Sleep(20000) 50 instances are instanciated straight away, and about 2-4 threads are used to do it - which in fact I consider normal. Could somebody explain why when Thread.Sleep causes those funny delays in creating instances?

    Read the article

  • C# WinForms. Multiple Forms in separate threads

    - by Calum Murray
    I'm trying to run an ATM Simulation in C# with Windows Forms that can have more than one instance of an ATM machine transacting with a bank account simultaneously. The idea is to use semaphores/locking to block critical code that may lead to race conditions. My question is this: How can I run two Forms simultaneously on separate threads? In particular, how does all of this fit in with the Application.Run() that's already there? Here's my main class: public class Bank { private Account[] ac = new Account[3]; private ATM atm; public Bank() { ac[0] = new Account(300, 1111, 111111); ac[1] = new Account(750, 2222, 222222); ac[2] = new Account(3000, 3333, 333333); Application.Run(new ATM(ac)); } static void Main(string[] args) { new Bank(); } } ...that I want to run two of these forms on separate threads... public partial class ATM : Form { //local reference to the array of accounts private Account[] ac; //this is a reference to the account that is being used private Account activeAccount = null; private static int stepCount = 0; private string buffer = ""; // the ATM constructor takes an array of account objects as a reference public ATM(Account[] ac) { InitializeComponent(); //Sets up Form ATM GUI in ATM.Designer.cs this.ac = ac; } ... I've tried using Thread ATM2 = new Thread(new ThreadStart(/*What goes in here?*/)); But what method do I put in the ThreadStart constructor, since the ATM form is event-driven and there's no one method controlling it? Thanks, Calum

    Read the article

  • Are rails timers reliable when using Net::HTTP?

    - by Frank
    Hi All. When reading data from a potentially slow website, I want to ensure that get_response can not hang, and so added a timer to timeout after x seconds. So far, so good. I then read http://ph7spot.com/musings/system-timer which illustrates that in certain situations timer.rb doesn't work due to ruby's implementation of threads. Does anyone know if this is one of these situations? url = URI.parse(someurl) begin Timeout::timeout(30) do response = Net::HTTP.get_response(url) @responseValue = CGI.unescape(response.body) end rescue Exception = e dosomething end

    Read the article

  • Using SetThreadAffinityMask function imported from kernel32.dll in C # code.

    - by DotNetBeginner
    I am trying to set Thread Affinity using SetThreadAffinityMask function imported from kernel32.dll in C # code of mine. This is how I import SetThreadAffinityMask function from "kernel32.dll" in my C# .net code [DllImport("kernel32.dll")] static extern IntPtr SetThreadAffinityMask(IntPtr hThread, IntPtr dwThreadAffinityMask); I am creating 3 threads Thread t1=new Thread(some delegate); Thread t2=new Thread(some delegate); Thread t3=new Thread(some delegate); I wish to set Thread affinity for t1,t2 & t3 for which I am using SetThreadAffinityMask function. But I am not getting how to pass parameters to this function. SetThreadAffinityMask takes two parameters 1. HANDLE hThread 2. DWORD_PTR dwThreadAffinityMask Please help me in using SetThreadAffinityMask function in C# Thanks in advance !

    Read the article

  • CAsyncSocket and ThreadPool problem

    - by zabulus
    I have a server application with such structure: There is one object, call him Server, that in endless cycle listens and accepts connections. I have descendant class from CAsyncSocket, that has overriden event OnReceive, call him ProxySocket. Also I have a thread pool with early created threads. When connection is received by server object he accepts the new connection on the new object ProxySocket. When data arrives to the ProxySocket, he creates a command object and gives it to thread pool. In this command object I giving the socket handle of a ProxySocket. When new object of command is creating - I creating a new Socket in working thread and attach handle to it. My issue is next: When command ends, socket doesn't close, I just detach handle it and set CSocket handle to INVALID_SOCKET value, as planned. But my first ProxySocket object doesn't receives messages of new data receiving after that. How can I solve this?

    Read the article

  • Add multiples Picturebox using ThreadPool

    - by Pmdusso
    Hi! Im doing a Naval Battle for University. I decided to do it in C#. My board is 20 x 20 of mini (20x20) PictureBoxes. The problem is when I load the board I got a huuuge delay for draw all of them in the panel which contains them. So I thought to ThreadPool my method to escale the picuteres boxes creation and drawing fester. Is this the correct aproach? I'm wondering if even if I launch 20 threads to create and set the picturesoboxes together I will still have the graphic delay. (I wont past code right now because maybe the answer independs of it... if not, I past next :) Sorry the bad english, Thanks folks!

    Read the article

  • gdb: Cannot find new threads: generic error

    - by Alexander Gladysh
    When I run GDB against a program which loads a .so which is linked to pthreads, GDB reports error "Cannot find new threads: generic error". I probably miss something in my Ubuntu configuration (as it was installed from minimal install). Any clues? $ gdb --args lua -lluarocks.require GNU gdb (GDB) 7.0-ubuntu Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /usr/bin/lua...(no debugging symbols found)...done. (gdb) run Starting program: /usr/bin/lua -lluarocks.require Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio require 'ev' [Thread debugging using libthread_db enabled] Cannot find new threads: generic error (gdb) q A debugging session is active. Inferior 1 [process 4986] will be killed. Quit anyway? (y or n) y This function gets called on require 'ev': http://github.com/brimworks/lua-ev/blob/master/lua_ev.c#L25-65 Additional information about my system: $ uname -a Linux localhost 2.6.31-20-generic #58-Ubuntu SMP Fri Mar 12 04:38:19 UTC 2010 x86_64 GNU/Linux $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 9.10 Release: 9.10 Codename: karmic

    Read the article

  • I need to stop execution during recursive algorithm

    - by Shaza
    Hey, I have a problem in choosing the right method to accomplish my goal. I'm working on Algorithms teaching system, I'm using C#. I need to divide my algorithm into steps, each step will contain a recursion. I have to stop execution after each step, user can then move to the next step(next recursion) using a button in my GUI. After searching, threads was the right choice, but I found several methods: (Thread.sleep/interrupt): didn't work, my GUI freezed !! (Suspend/Resume): I've read that it's a bad idea to use. (Waithandles): still reading about them. (Monitor wait/resume). I don't have much time to try and read all previous methods, please help me in choosing the best method that fits my system.Any suggestions are extremal welcomed.

    Read the article

  • My Thread Programs Crash

    - by zp26
    I have a problem with threads objectiveC. The line of code below contains the recv block the program waiting for a datum. My intention is to launch a thread parallel to the program so that this statement does not block any application. I put this code in my program but when active switch the program crashes. Enter the code. -(IBAction)Chat{ if(switchChat.on){ buttonInvio.enabled = TRUE; fieldInvio.enabled = TRUE; [NSThread detachNewThreadSelector:@selector(riceviDatiServer) toTarget:self withObject:nil]; } else { buttonInvio.enabled = FALSE; fieldInvio.enabled = FALSE; } -(void)riceviDatiServer{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init]; int ricevuti; NSString *datiRicevuti; ricevuti = recv(temp, &datiRicevuti, datiRicevuti.length, 0); labelRicezione.text = [[NSString alloc] initWithFormat:@"%s.... %d", datiRicevuti, ricevuti]; [pool release]; }

    Read the article

  • Measuring CPU time per-thread on Windows

    - by Eli Courtwright
    I'm developing a long-running multi-threaded Python application for Windows, and I want the process to know the CPU time that each of its threads has taken. I can get the overall times for the entire process with os.times() but I need to know the per-thread times. I know that there are external tools such as the Sysinternals Process Explorer, but my program itself needs to have this information. If I were on Linux, I look in the /proc filesystem, as described here. If I were writing C code, I'd use the GetThreadTimes call, as described here. So how can I accomplish this on Windows using Python?

    Read the article

  • How does one implement a truly asynchronous java thread

    - by Ritesh M Nayak
    I have a function that needs to perfom two operations, one which finishes fast and one which takes a long time to run. I want to be able to delegate the long running operation to a thread and I dont care when the thread finishes, but the threads needs to complete. I implemented this as shown below , but, my secondoperation never gets done as the function exits after the start() call. How I can ensure that the function returns but the second operation thread finishes its execution as well and is not dependent on the parent thread ? public void someFunction(String data) { smallOperation() Blah a = new Blah(); Thread th = new Thread(a); th.Start(); } class SecondOperation implements Runnable { public void run(){ // doSomething long running } }

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >