lens adapter – Kodak series VI ring size 44.5mm with wider threads

The top is a Kodak series V to VI step up ring. I need the VI portion with threads (I don’t need the smaller series V hole).

enter image description here

They are both same 44.5mm diameter but the lower black original one has much wider threads. The kodak one has very thin threads. Do you know of other ring that is 44.5mm but has wide threads too like the black one?

Auto Lock Threads | Nulled Scripts Download

[add] New Option | Removing the Auto-Lock rules after an auto-lock
[add] New Option | Auto Lock invert
[add] Info about the current rule
[add] Permissions for use the Auto-Lock

[fixed] If in ACP, the reset function is used for a thread, the thread is not opened
[fixed] Quote Problem

.

c – Do all threads share the same instance of a heap variable, or have different instances of a heap variable?

Computer Systems: a Programmer’s Perspective says:

12.4.2 Mapping Variables to Memory

Variables in threaded C programs are mapped to virtual memory
according to their storage classes:

Global variables. A global variable is any variable declared outside
of a func- tion. At run time, the read/write area of virtual memory
contains exactly one instance of each global variable that can be
referenced by any thread. For example, the global ptr variable
declared in line 5 has one run-time instance in the read/write area of
virtual memory. When there is only one instance of a variable, we will
denote the instance by simply using the variable name—in this case,
ptr.

Local automatic variables. A local automatic variable is one that is
declared inside a function without the static attribute. At run time,
each thread’s stack contains its own instances of any local automatic
variables. This is true even if multiple threads execute the same
thread routine. For example, there is one instance of the local
variable tid, and it resides on the stack of the main thread. We will
denote this instance as tid.m. As another example, there are two
instances of the local variable myid, one instance on the stack of
peer thread 0 and the other on the stack of peer thread 1. We will
denote these instances as myid.p0 and myid.p1, respectively.

Local static variables. A local static variable is one that is
declared inside a function with the static attribute. As with global
variables, the read/write area of virtual memory contains exactly one
instance of each local static variable declared in a program. For example, even though each peer
thread in our example program declares cnt in line 25, at run time there is
only one instance of cnt residing in the read/write area of virtual memory.
Each peer thread reads and writes this instance.

What about heap variables (created by malloc())? Do all threads share the same instance of a heap variable, or have different instances of a heap variable?

Thanks.

java – Will this time duration measurement in two threads give correct result?

A program I’m developing has two threads running similar but different task:

thread1:

timer1.start()
writeToExternalDB1(consumedData)
timer1.end()

thread2:

timer2.start()
writeToExternalDB2(consumedData)
timer2.end()

I want to compare the writing performance of the two external database. I have timers around the write operation so that I can collect some metrics. Those two threads are running concurrently.

My question is will this design give correct measurement result regarding to the time spent by each write operation?
My understanding is probably not because the processing time given by CPU to each thread may be different. Let’s say for thread1, after timer1 started, cpu will not move forward to the followed write operation, but switch to processing thread2 instead. This may introduce some gaps between timer1.start() and writeToExternalDB1(consumedData). However, in that case, should we regard this gap as negligible if we are processing a lot of data? What should I do to give the correct measurement result?

c – How to make two threads execute alternately?

I have two functions f1() and f2() I want f1() and f2() to execute
alternately, without using a loop: Not like this : loop {
f1();
f2(); }

I just want to use thread method My code is below:

 #include<stdio.h>
 #include<pthread.h>
 #include<unistd.h>
 #include<semaphore.h>

 void *f1(void *vargp);
 void *f2(void *vargp);

 static sem_t mutex;

 int main(int argc, char **argv) {
     pthread_t tid1, tid2;

     sem_init(&mutex, 0, 1);

     pthread_create(&tid1, NULL, f1, NULL);

     pthread_create(&tid2, NULL, f2, NULL);

     sleep(100);

     return 0;
 }

 void *f1(void *vargp) {
     pthread_detach(pthread_self());

     while (1) {
         sem_wait(&mutex);
         printf("In f1n");
         sleep(1);
         sem_post(&mutex);
     }

     return NULL;
 }

 void *f2(void *vargp) {
     pthread_detach(pthread_self());

     while(1) {
         sem_wait(&mutex);
         printf("In f2n");
         sleep(1);
         sem_post(&mutex);
     }

     return NULL;
 }

python – Using pygame with multiple threads

I have decided to try out pygame. I created a class that is supposed to handle all the GUI and game related stuff.

My idea is that I would have two seperate threads. One to handle the GUI and one to handle all the calculations the game does in the background.

import threading
import pygame
import pygame_gui


class Game ():


    engine_running = True
    gui_running = True
    clock = pygame.time.Clock()

    gui_framerate = 60.0
    engine_framerate = 120.0

    def __init__(self):

        pygame.init()
        pygame.display.set_caption('Explodotech')
        self.window_surface = pygame.display.set_mode((800, 600))
        self.background = pygame.Surface((800, 600))
        self.background.fill(pygame.Color('#000000'))

        self.manager = pygame_gui.UIManager((800, 600))

        ### Define GUI Elements here

        self.quit_button = pygame_gui.elements.UIButton(relative_rect=pygame.Rect((650, 500),
                        (100, 50)), text='Quit', manager=self.manager,                         
                        tool_tip_text = "Quit the game")

        ### Create and start the threads
        self.gui_thread = threading.Thread(target = self.gui_loop)
        self.engine_thread = threading.Thread(target = self.engine_loop, args = ())

        self.gui_thread.start()
        self.engine_thread.start()


    def start_polling(self):
        """Starts the main loop"""
        self.engine_running = True

    def stop_polling(self):
        """Stops the main loop"""
        self.engine_running = False

    def gui_loop(self):
        """Managing all the GUI stuff"""

        print ("GUI-loop started!")

        while self.gui_running:
            print("Polling GUI")
            dT = self.clock.tick_busy_loop(60)/1000.0

            for event in pygame.event.get():

                if event.type == pygame.QUIT:
                    self.gui_running = False

                if event.type == pygame.USEREVENT:
                    if event.user_type == pygame_gui.UI_BUTTON_PRESSED:
                        if event.ui_element == self.quit_button:
                            self.quit_button_event()

                self.manager.process_events(event)

            self.manager.update(dT)

            self.window_surface.blit(self.background, (0, 0))
            self.manager.draw_ui(self.window_surface)

            pygame.display.update()

    def engine_loop(self):
        """Doing all the game calculations in the background"""
        while self.engine_running:
            print(self.clock.tick_busy_loop(1))
        

    ### Define GUI events here

    def quit_button_event(self):
        """Shut down the GUI"""
        print("Quit-button pressed!")
        self.gui_running = False
        self.engine_running = False

Basically what’s happening here is that I have two threads one should run the “gui_loop” function the other should run the “engine_loop”. However when the gui thread starts and gets into its while-loop it get stuck. The windows goes unresponsive and I have to force windows to shut it down.
However if I a create a Game-object and call the function directly it all works fine (obviously commenting out the party where I create the Thread-object):

g = Game()
g.gui_loop()

Any pointers what I am doing wrong would be greatly appreciated!

java – Spawning two threads and if any of the threads returns true, let the main thread ignore the other and move on

Exact problem statement:

A main thread spawns 2 new threads, the main thread waits on this
threads with these conditions:

  1. if any of the threads returns True, then main thread moves on and prints the thread_id and timestamp of the thread.
  2. if both threads return false, finish execution and don’t print anything

My attempt:

public static void main(String() args) throws InterruptedException, ExecutionException{        
        FutureTask<Boolean> futureTask = new FutureTask<>(() -> {
          TimeUnit.MILLISECONDS.sleep(2000);
          System.out.println("Hello, World 1!");
          return true;
        });
        FutureTask<Boolean> futureTask2 = new FutureTask<>(() -> {
          System.out.println("Hello, World 2!");
          return true;
        });
        
        Thread t1 = new Thread(futureTask);
        Thread t2 = new Thread(futureTask2);
        t1.start();
        t2.start();
        
        // Wait for either to be done.
        while (!futureTask.isDone() && !futureTask2.isDone());

        if (futureTask.isDone()) {
          if (futureTask.get()) {
            System.out.println("1 - " + t1.getId() + " " + System.currentTimeMillis());
            return;
          }
        }

        if (futureTask2.isDone()) {
          if (futureTask2.get()) {
            System.out.println("2 - " + t2.getId() + " " + System.currentTimeMillis());
            return;
          }
        }
    }
}

When I run this a few times, sometimes thread 1 wins, sometimes 2, which seems to make sense to me. Appreciate any room for improvement or advice.