multithreading

java.lang.OutOfMemoryError: unable to create new native thread error using ChromeDriver and Chrome through Selenium in Spring boot

*爱你&永不变心* 提交于 2020-03-23 08:49:18
问题 We have selenium based web application developed using spring boot. The server is located as VM Instance at google cloud server. We have a thread base mechanism using Executor . Using selenium we open a chrome browser (headless) to perform operation and for each operation we create new thread. After facing outOfMemory error, if we restart cloud instance then within 1 hour it breaks again with the same error. Please find below the snippet which we used to create a new instance of executor

How do I properly use Threads to connect ping a url?

混江龙づ霸主 提交于 2020-03-23 07:49:38
问题 I am trying to ping a large amount of urls and retrieve information regarding the certificate of the url. As I read in this thoughtbot article here Thoughtbot Threads and others, I've read that the best way to do this is by using Threads. When I implement threads however, I keep running into Timeout errors and other problems for urls that I can retrieve successfully on their own. I've been told in another related question that I asked earlier that I should not use Timeout with Threads.

Write to excel file with multiple threads

允我心安 提交于 2020-03-22 08:23:20
问题 I am trying to write to datatable to excel which has large records. I am trying to achieve using divide and conquer strategy where each thread is assigned to write to respective sheets of excelworkbook.but I am getting file is readonly ,click Ok to override the file. class Program { int processorCount = 2; static volatile bool processing = true; DataTable employeeTable = new DataTable("Employee"); ManualResetEvent mre = new ManualResetEvent(false); AutoResetEvent ar = new AutoResetEvent(true)

type-safe Control.Invoke C#

混江龙づ霸主 提交于 2020-03-21 06:36:19
问题 I am programming a software in C# at work that contains 2 Threads a Thread that control a Form (Windows Forms) and interfaces with the user. a Thread that checks online data at the background. I need the second thread to print a massage on the form when the online data is irregular. because only the thread that created the control can change it, I am using delegates. the second thread calls the first thread to execute a delegate by the Control.Invoke method. Example: public partial class

UWP Update UI From Async Worker

为君一笑 提交于 2020-03-20 14:44:29
问题 I am trying to implement a long-running background process, that periodically reports on its progress, to update the UI in a UWP app. How can I accomplish this? I have seen several helpful topics, but none have all of the pieces, and I have been unable to put them all together. For example, consider a user who picks a very large file, and the app is reading in and/or operating on the data in the file. The user clicks a button, which populates a list stored on the page with data from the file

UWP Update UI From Async Worker

痴心易碎 提交于 2020-03-20 14:44:01
问题 I am trying to implement a long-running background process, that periodically reports on its progress, to update the UI in a UWP app. How can I accomplish this? I have seen several helpful topics, but none have all of the pieces, and I have been unable to put them all together. For example, consider a user who picks a very large file, and the app is reading in and/or operating on the data in the file. The user clicks a button, which populates a list stored on the page with data from the file

Optimizing parsing of massive python dictionary, multi-threading

淺唱寂寞╮ 提交于 2020-03-18 09:59:31
问题 Let's take a small example python dictionary, where the values are lists of integers. example_dict1 = {'key1':[367, 30, 847, 482, 887, 654, 347, 504, 413, 821], 'key2':[754, 915, 622, 149, 279, 192, 312, 203, 742, 846], 'key3':[586, 521, 470, 476, 693, 426, 746, 733, 528, 565]} Let's say I need to parse the values of the lists, which I've implemented into the following function: def manipulate_values(input_list): return_values = [] for i in input_list: new_value = i ** 2 - 13 return_values

Data race with detached pthread detected by valgrind

穿精又带淫゛_ 提交于 2020-03-18 07:26:21
问题 I am creating two detached pthread: pthread_attr_t tha1; void* fun1(void*){ return 0; } void* fun2(void*){ return 0; } int main(){ pthread_t th1, th2; pthread_attr_init(&tha1); pthread_attr_setdetachstate(&tha1, PTHREAD_CREATE_DETACHED); pthread_create( &th1, &tha1, fun1, 0); pthread_create( &th2, &tha1, fun2, 0); pthread_attr_destroy(&tha1); pthread_exit((void*) 0); return 0; } With the above code valgrind (helgrind tool) shows data race: Possible data race during write of size 1 at

Data race with detached pthread detected by valgrind

有些话、适合烂在心里 提交于 2020-03-18 07:26:10
问题 I am creating two detached pthread: pthread_attr_t tha1; void* fun1(void*){ return 0; } void* fun2(void*){ return 0; } int main(){ pthread_t th1, th2; pthread_attr_init(&tha1); pthread_attr_setdetachstate(&tha1, PTHREAD_CREATE_DETACHED); pthread_create( &th1, &tha1, fun1, 0); pthread_create( &th2, &tha1, fun2, 0); pthread_attr_destroy(&tha1); pthread_exit((void*) 0); return 0; } With the above code valgrind (helgrind tool) shows data race: Possible data race during write of size 1 at

c++ Threads inside for loop print wrong values

霸气de小男生 提交于 2020-03-18 03:28:28
问题 I'm trying to understand Multi-threading in c++, but I'am stuck in this problem: if I launch threads in a for loop they print wrong values. This is the code: #include <iostream> #include <list> #include <thread> void print_id(int id){ printf("Hello from thread %d\n", id); } int main() { int n=5; std::list<std::thread> threads={}; for(int i=0; i<n; i++ ){ threads.emplace_back(std::thread([&](){ print_id(i); })); } for(auto& t: threads){ t.join(); } return 0; } I was expecting to get printed