As a team-building exercise during their week-long stay at Duke University during training camp, the Nets spent an evening taking in an advance screening of “Captain Phillips,” the new film starring Tom Hanks.

“The movie was good,” said Fred Galloway, the Nets’ assistant director of team security.

If anyone should know, it would be Galloway.

Before joining the Nets before last season, Galloway spent six years working as an investigator on an FBI counter terrorism team, after working in the New York Police Department’s Intelligence Division.

His team’s coverage territory included the Horn of Africa — and was the one called on to complete a mission to bring Hanks’ antagonist in the movie, pirate Abduwali Muse, back to the United States after the Navy SEALs had rescued Phillips from captivity.

“I was at home, and I got [an email] that an American tanker ship, the Maersk Alabama, had been hijacked off the Coast of Aden, which was our responsibility,” said Galloway, who works with the Nets’ director of team security, Robert Masiello. “So, I had to put a team together and get out there.”

Galloway, who said he always had a “ready bag” packed so he could leave at any time, woke up to that email, went into work at Stewart Air Force Base, then headed straight to Washington. By the end of the day, was on a Gulfstream V jet headed to Cyprus for the first leg of their journey, accompanied by a team of eight, along with three FBI pilots.

From there, the team traveled to Camp Lemonnier in Djibouti, where they then took a two-hour helicopter ride to the USS Boxer.

“They debriefed us before we got on [the helicopter] and they told us there were reports there are [rocket-propelled grenades] out there looking to shoot down this helicopter because of the pirate situation,” Galloway said. “So we had two gunners on the helicopter who were looking around [for shooters].”

And though the threat of a rocket taking down the helicopter was trouble enough, that wasn’t the only issue with the flight.

“Inside that helicopter, it had to be 120 degrees,” Galloway said, accounting for the tactical gear they were wearing, plus the searing Middle Eastern heat. “It’s like being inside a car engine. … It’s 120 degrees with oil dripping everywhere.”

Finally, the helicopter landed on the aircraft carrier, where the team was brought inside to take control of Muse, who they would bring back to America. Then, after taking inventory of the three pirates killed during the raid and completing the exchange, Galloway, Muse and his team began the long trip back to the U.S., and the equally lengthy debriefing process that went along with it.

Over time, Galloway established a good rapport with Muse, who eventually would reveal his real age — he confirmed he was over 20, allowing him to be tried as an adult, while he and his family initially said he was 16 — as well as how he put together his team to make the initial raid of the Maersk Alabama.

“He explained how he went to the beach [the morning of the hijacking] and how everybody wanted to go with him, but he picked the people that he thought could get it done,” Galloway said. “We only later found out just how big piracy is over there.”

In addition to getting information out of Muse — who was later discovered to be involved in at least one other hijacking — there also were some lighter moments, including introducing the Somali pirate to American culture, on the trip back to Stewart Air Force Base.

“A lot of people said that they didn’t understand why he was smiling [when he got off the plane],” Galloway said, laughing. “Well, I was telling him on the plane ride over that he’s going to be bigger than Elvis. He had no idea who Elvis was, so I showed him a picture … but when he stepped out of the truck, he saw about 300 news media people waiting for him and lit up.”

Including the Muse case, Galloway was involved in five such cases during his tenure with the FBI, including the rescue of aid worker Jessica Buchanan in January 2012, and he admitted he doesn’t miss the work.

“I don’t,” he said. “For this, it’s different because we’ll go away [now] for a game for two or three days and you’re back home in your bed. But I would tell my family I’m going away for a day or a couple of days, and I would wind up being gone for a month and a half, or two months or three months.

“When you come back, you want to kiss the American ground after you see how other people live.”

As you might expect, Galloway said the movie, while good, stirred up some mixed feelings in him as he relived some of the more intense moments of his entire life. He also said, as you might expect, while the movie is historically accurate overall, there are some parts of the plot that have been tweaked and embellished in order to make it work as a dramatic movie.

“Sometimes you were sitting there and you remember the emotion of why you were there,” Galloway said. “Then you look at Tom Hanks portraying Captain Phillips and you go, ‘Wow. He really captured it.’ He was really good.

“There are certain things that we know are true and false, because they have to twist it [for dramatic purposes] … so you’d go through and say, ‘That happened. That didn’t happen. That happened with a twist.’

“I enjoyed the movie, and I think everyone is going to enjoy it, if they don’t cry.”

Galloway’s office at the team’s practice facility is filled with mementos from his time working in law enforcement, including a picture of the team that went with him on Muse mission. Some of the players who had been into the office knew about his background before they went to see the movie, but others were blown away by the news when they found out later.

“They were like, ‘We’ve got the real deal here!’ ” Galloway said with a laugh.

Galloway enjoys the chance to be part of the Nets, who enter a season with high expectations of a deep playoff run. But he admitted for all of the talk of camaraderie and teamwork inside the walls at the team’s facility, it doesn’t compare to the adrenaline rush he would get from working to save lives behind enemy lines.

“Once we were there, it’s like everything else in life … you have to make the best of it until you’re out,” he said. “We were all from different backgrounds, we all worked in different parts of the country, we all specialized in different areas and we put it together, went there and got it done.

“[Basketball] is entertainment. This is something that for people who have to work really hard, they can go home and have a little enjoyment for a couple hours at a game. But when we go out there and do this stuff for Americans, there’s no room for mistakes, because one mistake and you can leave with eight and come back with seven or six or five or four, or not get the job done and lose an American.

“Nobody wants an ‘L’ on a hostage case.”