multithreading

Java Memory error: unable to create new native thread

。_饼干妹妹 提交于 2020-08-01 09:26:22
问题 I get this error on my UNIX server, when running my java server: Exception in thread "Thread-0" java.lang.OutOfMemoryError: unable to create new native thread at java.lang.Thread.start0(Native Method) at java.lang.Thread.start(Thread.java:640) at [... where ever I launch a new Thread ...] It happens everytime I have about 600 threads running. I have set up this variable on the server: $> ulimit -s 128 What looks strange to me is the result of this command, which I ran when the bug occured the

Why slim reader/writer exclusive lock outperformance the shared one?

独自空忆成欢 提交于 2020-07-31 14:48:28
问题 I have tested the performance of slim reader/writer lock under windows 7 using the codefrom Windows Via C/C++ . The result surprised me that the exclusive lock out performance the shared one. Here are the code and the result. unsigned int __stdcall slim_reader_writer_exclusive(void *arg) { //SRWLOCK srwLock; //InitializeSRWLock(&srwLock); for (int i = 0; i < 1000000; ++i) { AcquireSRWLockExclusive(&srwLock); g_value = 0; ReleaseSRWLockExclusive(&srwLock); } _endthreadex(0); return 0; }

How to design an execution engine for a sequence of tasks

点点圈 提交于 2020-07-31 07:28:50
问题 I am trying to code a problem in Java where I have to execute a bunch of tasks. Problem Execute a job which consists of multiple tasks and those tasks have dependencies among them. A job will have a list of tasks and each such task will further have a list of successor tasks (Each successor task will have its own successor tasks - you can see the recursive nature here). Each successor task can start its execution if - It is configured to be executed on partial execution of its predecessor

How to identify / get automated hints with cyclic object initialization causing deadlocks in Scala?

我的梦境 提交于 2020-07-31 04:17:33
问题 The following code runs into future timeouts (in Scala 2.x and Dotty, -Xcheckinit or -Ycheck-init does not help here) because of cyclic object initialization. In complex projects these cycles usually are hidden very well. Is there any possiblity of getting help from the compiler or at least at runtime? How do you prevent this from happening in a multithreaded environment? import scala.concurrent.Future import scala.concurrent._ import scala.concurrent.duration._ import scala.concurrent

Spring - Have TaskExecutor and TaskScheduler backed by the same thread pool

我是研究僧i 提交于 2020-07-30 03:29:06
问题 I am a bean for TaskScheduler and TaskExecutor as following: @Bean public TaskScheduler taskScheduler() { ThreadPoolTaskScheduler s = new ThreadPoolTaskScheduler(); s.setThreadNamePrefix("Task-Scheduler-"); s.setPoolSize(10); s.setRemoveOnCancelPolicy(true); return s; } @Bean public TaskExecutor taskExecutor() { ThreadPoolTaskExecutor e = new ThreadPoolTaskExecutor(); e.setThreadNamePrefix("Task-Executor-"); e.setMaxPoolSize(10); e.setCorePoolSize(10); return e; } Is it possible to share the

C# Winforms: A thread that can control the UI and can “sleep” without pausing the whole program. How?

冷暖自知 提交于 2020-07-30 02:39:47
问题 OK... Looks like WinForms and Threading in the same program is something that I can't master easily. I'm trying to make a custom Numeric Up Down out of two picture boxes (used a buttons) and a text box. Yes, I can use the default NumericUpDown form, but I want to make a different looking one. I have tried to do that with timers (System.Windows.Forms.Timer). The problem is that when one timer meets "Thread.Sleep(int)", the whole program "falls to sleep". I tried with threads. Some types of

How to stop the thread execution in C++

社会主义新天地 提交于 2020-07-28 04:46:10
问题 I created one thread in my main program, thread execution has to stop once the main program will terminate. I am using reader.join(); to terminate the thread execution. But it is not stopping the execution. I tried with below-mentioned code, I am using thread.join(); function, but it is failed to terminate a thread. And after the main program also my thread is kept executing. #include <algorithm> #include <array> #include <atomic> #include <mutex> #include <queue> #include <cstdint> #include

How to stop the thread execution in C++

那年仲夏 提交于 2020-07-28 04:43:45
问题 I created one thread in my main program, thread execution has to stop once the main program will terminate. I am using reader.join(); to terminate the thread execution. But it is not stopping the execution. I tried with below-mentioned code, I am using thread.join(); function, but it is failed to terminate a thread. And after the main program also my thread is kept executing. #include <algorithm> #include <array> #include <atomic> #include <mutex> #include <queue> #include <cstdint> #include

How to create a thread local variable inside of a Rust struct?

空扰寡人 提交于 2020-07-23 09:08:27
问题 I need a thread local variable, ideally stored in a struct which currently stores most of my program's global state. The first way I can see to do this is to use the thread_local! macro, however I would like to keep this thread local within my state struct. The second way I can see to achieve this is to have a HashMap<Thread,MyThreadLocalData> or similar between threads and the value of my thread local variable(s). I would then have a getter which uses thread::current to lookup the

python thread not exiting with atexit

橙三吉。 提交于 2020-07-23 06:50:16
问题 Here is my script. When I run it in a shell it just hangs indefinitely whereas I would expect it to terminate cleanly. import logging from logging import StreamHandler import pymsteams import queue import threading import atexit class TeamsHandler(StreamHandler): def __init__(self, channel_url): super().__init__() self.channel_url = channel_url self.queue = queue.Queue() self.thread = threading.Thread(target=self._worker) self.thread.start() atexit.register(self.queue.put, None) def _worker